********************************************************************************
* 								 CLEAN AND PROCESS							   *
********************************************************************************

clear all
set more off
set scheme s2color
grstyle init
grstyle set plain, horizontal grid dotted box
macro drop _all
est drop _all
set matsize 800
set seed 8675309

ssc install swindex, replace
ssc install ebalance, replace
ssc install estout, replace
ssc install did_imputation, replace
ssc install event_plot, replace
ssc install cem, replace

** Set Working Directory

if c(username) == "cb2257" {
global dir "~/Desktop"  // CWB's Directory
global main "${dir}/APSR Replication"
global code "${main}/Analysis"	
global data "${main}/Data"	
global figs "${main}/Figures"
global tabs "${main}/Tables"																			
}

if c(username) == "christopherblair" {
global dir "~/Desktop"  // CWB's Directory
global main "${dir}/APSR Replication"
global code "${main}/Analysis"	
global data "${main}/Data"	
global figs "${main}/Figures"
global tabs "${main}/Tables"																			
}

else if c(username) == "yourusername"{
global dir "~/yourfilepath"  // YOUR Directory
}

cd "${main}"

********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************

import delimited "${data}/Survey/survey_completes_geocoded.csv", clear
est drop _all

********************************************************************************
*								CLEAN SURVEY DATA							   *
********************************************************************************

gen start_date = dofc(clock(startdate, "MD20Yhm"))
format start_date %td

gen end_date = dofc(clock(enddate, "MD20Yhm"))
format end_date %td

drop startdate enddate progress recordeddate finished recipientlastname recipientfirstname recipientemail externalreference countyns affgeoid namelsad stusps rid age_1 gender_1 hhi ethnicity hispanic education_1 political_party region zip clicked userlanguage rel_import_time_firstclick rel_import_time_lastclick rel_import_time_pagesubmit rel_import_time_clickcount

order start_date end_date
label var start_date "Interview Start Date"
label var end_date "Interview End Date"

gen obsdrop=0
label var obsdrop "Observation to Drop"
replace obsdrop=1 if start_date!=end_date
replace obsdrop=1 if status=="Survey Preview"
replace obsdrop=1 if distributionchannel=="preview"
drop status distributionchannel

gen wkyr=wofd(start_date)
format wkyr %tw

gen wave=.
replace wave=1 if wkyr<=3256
replace wave=2 if wkyr==3257
replace wave=3 if wkyr==3258
replace wave=4 if wkyr==3259
replace wave=5 if wkyr==3261
replace wave=6 if wkyr==3262
replace wave=7 if wkyr==3263
replace wave=8 if wkyr==3264
replace wave=9 if wkyr==3265
replace wave=10 if wkyr==3266
drop wkyr
label var wave "Survey Wave"
order wave, first

ren durationinseconds duration
label var duration "Interview Duration (Seconds)"
gen fastest10=(duration<=241)
label var fastest10 "Fast Interview (Duration in Bottom Decile)"
gen slowest10=(duration>=1061)
label var slowest10 "Slow Interview (Duration in Top Decile)"
replace obsdrop=1 if fastest10==1 | slowest10==1

gen respondent_id=_n
label var respondent_id "Respondent ID"
order respondent_id responseid, first
ren responseid lucid_id
label var lucid_id "Lucid ID"

ren locationlatitude latitude
label var latitude "Latitude"
ren locationlongitude longitude
label var longitude "Longitude"
order geoid state_name statefp name countyfp, a(longitude)
label var geoid "County ID"
replace obsdrop=1 if geoid==.
ren state_name state
label var state "State"
label var statefp "State FIPS"
ren name county
label var county "County"
label var countyfp "County FIPS"

gen woman=(gender=="Female")
replace gender="0" if gender=="Neither/Prefer not to say"
replace gender="1" if gender=="Male"
replace gender="2" if gender=="Female"
destring gender, replace
label define gender 0 "Neither/Prefer Not to Say" 1 "Male" 2 "Female"
label val gender gender
order woman, a(gender)
label var woman "Woman Respondent"
label var gender "Gender"

replace education="0" if education=="Elementary or some high school"
replace education="1" if education=="High school graduate/GED"
replace education="2" if education=="Some college/AssociateÃ¢â¬â¢s degree"
replace education="3" if education=="Trade or vocational certification"
replace education="4" if education=="College graduate"
replace education="5" if education=="Post-graduate degree"
destring education, replace
label define education 0 "Some High School or Less" 1 "High School" 2 "Some College" 3 "Trade Certification" 4 "College Degree" 5 "Graduate Degree"
label val education education
label var education "Education"
gen college=(education>=4)
label var college "College Graduate"
gen highschool=(inrange(education, 1,3))
label var highschool "High School Graduate"
order highschool college, a(education)

replace ideology="0" if ideology=="Extremely conservative"
replace ideology="1" if ideology=="Conservative"
replace ideology="2" if ideology=="Slightly conservative"
replace ideology="3" if ideology=="Moderate, middle of the road"
replace ideology="4" if ideology=="Slightly liberal"
replace ideology="5" if ideology=="Liberal"
replace ideology="6" if ideology=="Extremely liberal"
destring ideology, replace
label define ideology 0 "Very Conservative" 1 "Conservative" 2 "Somewhat Conservative" 3 "Moderate" 4 "Somewhat Liberal" 5 "Liberal" 6 "Very Liberal"
label val ideology ideology
label var ideology "Ideology"
gen conservative=(ideology<=2)
label var conservative "Conservative"
gen liberal=(ideology>=4)
label var liberal "Liberal"
order conservative liberal, a(ideology)
replace partisanship="0" if partisanship=="Republican"
replace partisanship="1" if partisanship=="Independent"
replace partisanship="2" if partisanship=="Democrat"
destring partisanship, replace
ren partisanship party
label define party 0 "Republican" 1 "Independent" 2 "Democrat"
label val party party
label var party "Party ID"
gen republican=(party==0)
label var republican "Republican"
gen democrat=(party==2)
label var democrat "Democrat"
order republican democrat, a(party)
gen partisanship=.
replace partisanship=0 if partisanship_r=="Strong Republican"
replace partisanship=1 if partisanship_r=="Not very strong Republican"
replace partisanship=2 if partisanship_i=="Closer to the Republican Party"
replace partisanship=3 if partisanship_i=="Closer to the Democratic Party"
replace partisanship=4 if partisanship_d=="Not very strong Democrat"
replace partisanship=5 if partisanship_d=="Strong Democrat"
label define partisanship 0 "Strong Republican" 1 "Republican" 2 "Lean Republican" 3 "Lean Democrat" 4 "Democrat" 5 "Strong Democrat"
label val partisanship partisanship
label var partisanship "Partisanship"
order partisanship, a(party)
drop partisanship_d partisanship_r partisanship_i

gen botfilter1=(bot_filter_3=="Red" & bot_filter_5=="Green")
label var botfilter1 "Passed Bot Filter"
gen botfilter2=(bot_filter_3=="Red" | bot_filter_5=="Green")
label var botfilter2 "Passed One Leg of Bot Filter"
order botfilter1 botfilter2, b(obsdrop)
replace obsdrop=1 if botfilter1==0
drop bot_filter_1 bot_filter_2 bot_filter_3 bot_filter_4 bot_filter_5 bot_filter_6

replace religiosity="0" if religiosity=="Never"
replace religiosity="1" if religiosity=="Once a year or less"
replace religiosity="2" if religiosity=="A few times a year"
replace religiosity="3" if religiosity=="A few times a month"
replace religiosity="4" if religiosity=="Once a week"
replace religiosity="5" if religiosity=="More than once a week"
destring religiosity, replace
label define religiosity 0 "Attend Worship: Never" 1 "Attend Worship: Once a Year" 2 "Attend Worship: Few Times a Year" 3 "Attend Worship: Few Times a Month" 4 "Attend Worship: Once a Week" 5 "Attend Worship: Few Times a Week"
label val religiosity religiosity
label var religiosity "Religiosity"

replace native_born="0" if native_born=="Prefer not to say"
replace native_born="1" if native_born=="Somewhere Else"
replace native_born="2" if native_born=="United States"
destring native_born, replace
label define native_born 0 "Prefer Not to Say" 1 "Born Outside US" 2 "Born in US"
label val native_born native_born
label var native_born "Nativity"
gen native=(native_born==2)
label var native "Born in US"
order native, a(native_born)

replace employment="0" if employment=="Unemployed "
replace employment="1" if employment=="Retired"
replace employment="2" if employment=="Homemaker"
replace employment="3" if employment=="Student"
replace employment="4" if employment=="Self-employed"
replace employment="5" if employment=="Employed part time "
replace employment="5" if employment=="Employed full time"
destring employment, replace
label define employment 0 "Unemployed" 1 "Retired" 2 "Homemaker" 3 "Student" 4 "Self-Employed" 5 "Employed Part-Time" 6 "Employed Full-Time"
label val employment employment
label var employment "Employment Status"
gen employed=(employment>=4)
order employed, a(employment)
label var employed "Employed"

replace age="65" if age=="Sixty five"
replace age="24" if age=="L24"
replace age="58" if age==",58"
replace age="22" if age=="222"
replace age="39" if age=="3("
replace age="33" if age=="3e"
destring age, replace
label var age "Age"
replace obsdrop=1 if age<18

replace trust_govt="0" if trust_govt=="Only some of the time"
replace trust_govt="1" if trust_govt=="Most of the time"
replace trust_govt="2" if trust_govt=="Just about always"
destring trust_govt, replace
label define trust_govt 0 "Sometimes" 1 "Most of the Time" 2 "Always"
label val trust_govt trust_govt
label var trust_govt "Trust Government"

replace pol_interest="0" if pol_interest=="Hardly at all"
replace pol_interest="1" if pol_interest=="Only now and then"
replace pol_interest="2" if pol_interest=="Some of the time"
replace pol_interest="3" if pol_interest=="Most of the time"
destring pol_interest, replace
label define pol_interest 0 "Hardly at All" 1 "Now and Then" 2 "Some of the Time" 3 "Most of the Time"
label val pol_interest pol_interest
label var pol_interest "Political Interest"

replace latino="0" if latino=="No"
replace latino="0" if latino=="Perfer not to say"
replace latino="1" if latino=="Yes"
destring latino, replace
ren latino race_latinx
label var race_latinx "Race: Latinx"
gen race_white=(race_1=="White or Caucasian")
label var race_white "Race: White/Caucasian"
gen race_black=(race_2=="Black or African American")
label var race_black "Race: Black/African American"
gen race_indigenous=(race_3=="American Indian/Native American or Alaska Native" | race_5=="Native Hawaiian or Other Pacific Islander")
label var race_indigenous "Race: American Indian/Native American/Alaska Native/Native Hawaiian/Pacific Islander"
gen race_asian=(race_4=="Asian")
label var race_asian "Race: Asian"
gen race_other=(race_6=="Other" | race_7=="Prefer not to say")
label var race_other "Race: Other"
egen race_sum=rowtotal(race_white race_black race_latinx race_asian race_indigenous race_other)
gen race_multi=race_sum>1
replace race_multi=0 if race_white==1 & race_latinx==1
label var race_multi "Race: Multiracial"
order race_white race_black race_multi race_latinx race_asian race_indigenous race_other, a(pol_interest)
drop race_1 race_2 race_3 race_4 race_5 race_6 race_7 race_sum
gen race=.
replace race=0 if race_multi==0 & race_white==1
replace race=1 if race_multi==0 & race_black==1
replace race=2 if race_multi==0 & race_latinx==1
replace race=3 if race_multi==0 & race_asian==1
replace race=4 if race_multi==0 & race_indigenous==1
replace race=5 if race_multi==0 & race_other==1
replace race=6 if race_multi==1
label define race 0 "White" 1 "Black" 2 "Latinx" 3 "Asian" 4 "Indigenous" 5 "Other" 6 "Multiracial"
label val race race
label var race "Race"
order race, a(pol_interest)

replace income="0" if income=="Prefer not to say"
replace income="1" if income=="Less than $25,000"
replace income="2" if income=="$25,000-$49,999"
replace income="3" if income=="$50,000-$74,999"
replace income="4" if income=="$75,000-$99,999"
replace income="5" if income=="$100,000-$149,999"
replace income="6" if income=="$150,000 or more"
destring income, replace
label define income 0 "Prefer Not to Say" 1 "< $25,000" 2 "$25,000-$49,999" 3 "$50,000-$74,999" 4 "$75,000-$99,999" 5 "$100,000-$149,999" 6 "$150,000+"
label val income income
label var income "Income"

replace empathy_1="0" if empathy_1=="Does not describe me at all"
replace empathy_1="1" if empathy_1=="Describes me very little"
replace empathy_1="2" if empathy_1=="Describes me moderately well"
replace empathy_1="3" if empathy_1=="Describes me fairly well"
replace empathy_1="4" if empathy_1=="Describes me very well"
destring empathy_1, replace
label define empathy_1 0 "Doesn't Describe Me" 1 "Describes Me Little" 2 "Describes Me Somewhat" 3 "Describes Me Fairly Well" 4 "Describes Me Well"
label val empathy_1 empathy_1
ren empathy_1 empathy1
label var empathy1 "Feel protective when I see others being taken advantage."
replace empathy_2="4" if empathy_2=="Does not describe me at all"
replace empathy_2="3" if empathy_2=="Describes me very little"
replace empathy_2="2" if empathy_2=="Describes me moderately well"
replace empathy_2="1" if empathy_2=="Describes me fairly well"
replace empathy_2="0" if empathy_2=="Describes me very well"
destring empathy_2, replace
label define empathy_2 0 "Describes Me Well" 1 "Describes Me Fairly Well" 2 "Describes Me Somewhat" 3 "Describes Me Little" 4 "Doesn't Describe Me"
label val empathy_2 empathy_2
ren empathy_2 empathy2
label var empathy2 "Other's misfortunes do not bother me."
replace empathy_3="4" if empathy_3=="Does not describe me at all"
replace empathy_3="3" if empathy_3=="Describes me very little"
replace empathy_3="2" if empathy_3=="Describes me moderately well"
replace empathy_3="1" if empathy_3=="Describes me fairly well"
replace empathy_3="0" if empathy_3=="Describes me very well"
destring empathy_3, replace
label define empathy_3 0 "Describes Me Well" 1 "Describes Me Fairly Well" 2 "Describes Me Somewhat" 3 "Describes Me Little" 4 "Doesn't Describe Me"
label val empathy_3 empathy_3
ren empathy_3 empathy3
label var empathy3 "If I'm sure I'm right, I don't listen to other's opinions."
replace empathy_4="0" if empathy_4=="Does not describe me at all"
replace empathy_4="1" if empathy_4=="Describes me very little"
replace empathy_4="2" if empathy_4=="Describes me moderately well"
replace empathy_4="3" if empathy_4=="Describes me fairly well"
replace empathy_4="4" if empathy_4=="Describes me very well"
destring empathy_4, replace
label define empathy_4 0 "Doesn't Describe Me" 1 "Describes Me Little" 2 "Describes Me Somewhat" 3 "Describes Me Fairly Well" 4 "Describes Me Well"
label val empathy_4 empathy_4
ren empathy_4 empathy4
label var empathy4 "I try to see both sides to every story."
swindex empathy1 empathy2 empathy3 empathy4, gen(empathy)
order empathy, b(empathy1)
label var empathy "Empathy Index"
drop empathy1 empathy2 empathy3 empathy4

gen community_flood=(experience_cc_com_1=="Floods")
label var community_flood "Community Experienced Flood in Past Year"
gen community_hurricane=(experience_cc_com_2=="Hurricanes")
label var community_hurricane "Community Experienced Hurricane in Past Year"
gen community_fire=(experience_cc_com_3=="Wildfires")
label var community_fire "Community Experienced Wildfire in Past Year"
gen community_drought=(experience_cc_com_4=="Droughts")
label var community_drought "Community Experienced Drought in Past Year"
gen community_heat=(experience_cc_com_5=="Heatwaves")
label var community_heat "Community Experienced Heatwave in Past Year"
gen community_cc=(community_flood==1 | community_hurricane==1 | community_fire==1 | community_drought==1 | community_heat==1)
label var community_cc "Community Experienced Extreme Weather in Past Year"
order community_cc community_hurricane community_flood community_fire community_drought community_heat, a(empathy)
drop experience_cc_com_1 experience_cc_com_2 experience_cc_com_3 experience_cc_com_4 experience_cc_com_5 experience_cc_com_6

gen personal_flood=(experience_cc_per_1=="Floods")
label var personal_flood "Personally Experienced Flood in Past Year"
gen personal_hurricane=(experience_cc_per_2=="Hurricanes")
label var personal_hurricane "Personally Experienced Hurricane in Past Year"
gen personal_fire=(experience_cc_per_3=="Wildfires")
label var personal_fire "Personally Experienced Wildfire in Past Year"
gen personal_drought=(experience_cc_per_4=="Droughts")
label var personal_drought "Personally Experienced Drought in Past Year"
gen personal_heat=(experience_cc_per_5=="Heatwaves")
label var personal_heat "Personally Experienced Heatwave in Past Year"
gen personal_cc=(personal_flood==1 | personal_hurricane==1 | personal_fire==1 | personal_drought==1 | personal_heat==1)
label var personal_cc "Personally Experienced Extreme Weather in Past Year"
order personal_cc personal_hurricane personal_flood personal_fire personal_drought personal_heat, a(community_heat)
drop experience_cc_per_1 experience_cc_per_2 experience_cc_per_3 experience_cc_per_4 experience_cc_per_5 experience_cc_per_6

gen climmig_personal=(experience_cm_1=="I personally have moved because of climate-related reasons")
label var climmig_personal "Personal Climate Migration"
gen climmig_family=(experience_cm_2=="Someone in my family has moved because of climate-related reasons")
label var climmig_family "Family Climate Migration"
gen climmig_friend=(experience_cm_3=="A close friend has moved because of climate-related reasons")
label var climmig_friend "Friend Climate Migration"
gen climmig_acquaintance=(experience_cm_4=="An acquaintance has moved because of climate-related reasons")
label var climmig_acquaintance "Acquaintance Climate Migration"
gen climmig_know=(climmig_personal==1 | climmig_family==1 | climmig_friend==1 | climmig_acquaintance==1)
label var climmig_know "Know a Climate Migrant"
order climmig_know climmig_personal climmig_family climmig_friend climmig_acquaintance, a(personal_heat)
drop experience_cm_1 experience_cm_2 experience_cm_3 experience_cm_4 experience_cm_5

gen climmig_reason_flood=(cm_reason_1=="Floods")
label var climmig_reason_flood "Reason for Climate Migration: Floods"
gen climmig_reason_hurricane=(cm_reason_2=="Hurricanes")
label var climmig_reason_hurricane "Reason for Climate Migration: Hurricanes"
gen climmig_reason_fire=(cm_reason_4=="Wildfires")
label var climmig_reason_fire "Reason for Climate Migration: Wildfire"
gen climmig_reason_drought=(cm_reason_3=="Droughts" | cm_reason_5=="Droughts")
label var climmig_reason_drought "Reason for Climate Migration: Drought"
gen climmig_reason_heat=(cm_reason_6=="Heatwaves" | cm_reason_7_text=="Extreme heat and cold and an energy grid that is unstable" | cm_reason_7_text=="humid temperature" | cm_reason_7_text=="Because was too hot in the summer ")
label var climmig_reason_heat "Reason for Climate Migration: Heatwave"
gen climmig_reason_winter=(cm_reason_7_text=="winter weather" | cm_reason_7_text=="snow caved in my roof which cause a fire" | cm_reason_7_text=="snow" | cm_reason_7_text=="hard winters" | cm_reason_7_text=="cold" | cm_reason_7_text=="Too much snow " | cm_reason_7_text=="Too cold" | cm_reason_7_text=="Snow storms" | cm_reason_7_text=="Snow " | cm_reason_7_text=="Snow" | cm_reason_7_text=="Ice" | cm_reason_7_text=="Frozen weather" | cm_reason_7_text=="Freeze" | cm_reason_7_text=="Extreme Winter Cold" | cm_reason_7_text=="Cold winters" | cm_reason_7_text=="Cold winter weather" | cm_reason_7_text=="Cold weather " | cm_reason_7_text=="Cold weather" | cm_reason_7_text=="Cold and ice" | cm_reason_7_text=="Cold Snowy Winter" | cm_reason_7_text=="Blizzards " | cm_reason_7_text=="Extreme heat and cold and an energy grid that is unstable")
label var climmig_reason_winter "Reason for Climate Migration: Winter Weather"
gen climmig_reason_tornado=(cm_reason_7_text=="tornadoes" | cm_reason_7_text=="Tornadoes " | cm_reason_7_text=="Tornado's" | cm_reason_7_text=="Tornado destroyed their home " | cm_reason_7_text=="Tornado " | cm_reason_7_text=="Tornado" | cm_reason_7_text=="Lightning strike")
label var climmig_reason_tornado "Reason for Climate Migration: Tornadoes"
gen climmig_reason_other=(cm_reason_7_text!="" & climmig_reason_winter==0 & climmig_reason_tornado==0 & climmig_reason_heat==0)
label var climmig_reason_other "Reason for Climate Migration: Other"
drop cm_reason_1 cm_reason_2 cm_reason_3 cm_reason_4 cm_reason_5 cm_reason_6 cm_reason_7 cm_reason_7_text
order climmig_reason_hurricane climmig_reason_flood climmig_reason_fire climmig_reason_drought climmig_reason_heat climmig_reason_winter climmig_reason_tornado climmig_reason_other, a(climmig_acquaintance)

replace cm_scale="0" if cm_scale==""
replace cm_scale="1" if cm_scale=="Few people"
replace cm_scale="2" if cm_scale=="Some people"
replace cm_scale="3" if cm_scale=="Many people"
destring cm_scale, replace
label define cm_scale 0 "None" 1 "Few People" 2 "Some People" 3 "Many People"
label val cm_scale cm_scale
label var cm_scale "Scale of Climate Migration Experienced"
ren cm_scale climmig_scale
order climmig_scale, a(climmig_acquaintance)

replace rent_own="0" if rent_own=="Neither"
replace rent_own="1" if rent_own=="Rent"
replace rent_own="2" if rent_own=="Own"
destring rent_own, replace
label define rent_own 0 "Neither" 1 "Rent" 2 "Own"
label val rent_own rent_own
label var rent_own "Rent/Own Residence"
ren rent_own rentown
order rentown, a(income)
gen owner=(rentown==2)
label var owner "Home Owner"
order owner, a(rentown)

replace time_in_comm="0" if time_in_comm=="Less than 1 year"
replace time_in_comm="1" if time_in_comm=="1-3 years"
replace time_in_comm="2" if time_in_comm=="3-6 years"
replace time_in_comm="3" if time_in_comm=="7-10 years"
replace time_in_comm="4" if time_in_comm=="10 or more years"
destring time_in_comm, replace
label define time_in_comm 0 "< 1 Year" 1 "1-3 Years" 2 "4-6 Years" 3 "7-10 Years" 4 "10+ Years"
label val time_in_comm time_in_comm
label var time_in_comm "Time Living in Community"
ren time_in_comm timecomm
order timecomm, a(owner)

replace community_links="0" if community_links=="No, I am not a member of a a club, group, or association"
replace community_links="1" if community_links=="Yes, I am a member of one club, group, or association"
replace community_links="2" if community_links=="Yes, I am a member of more than one club, group, or association"
destring community_links, replace
label define community_links 0 "0 Groups" 1 "1 Group" 2 "2+ Groups"
label val community_links community_links
label var community_links "Membership in Community Groups"
order community_links, a(timecomm)
gen commgroup=(community_links>=1)
label var commgroup "Community Group"
order commgroup, a(community_links)

replace move_intent="0" if move_intent=="I have no plans to move someplace new"
replace move_intent="1" if move_intent=="I am planning on moving someplace new within the next year"
replace move_intent="2" if move_intent=="I am planning on moving someplace new within the next 1-3 years"
replace move_intent="3" if move_intent=="I am planning on moving someplace new within the next 3-6 years"
destring move_intent, replace
label define move_intent 0 "No Plans to Move" 1 "Move in Next Year" 2 "Move in 1-3 Years" 3 "Move in 3-6 Years"
label val move_intent move_intent
label var move_intent "Intentions to Move"
gen willmove=(move_intent>=1)
label var willmove "Intend to Move"
order willmove, a(move_intent)
replace move_coastal="0" if move_coastal=="Much closer to the coast"
replace move_coastal="1" if move_coastal=="Somewhat closer to the coast"
replace move_coastal="2" if move_coastal=="Neither closer to nor further from the coast"
replace move_coastal="3" if move_coastal=="Somewhat further away from the coast"
replace move_coastal="4" if move_coastal=="Much further away from the coast"
destring move_coastal, replace
label define move_coastal 0 "Much Closer to Coast" 1 "Somewhat Closer to Coast" 2 "Same Distance from Coast" 3 "Somewhat Further from Coast" 4 "Much Further from Coast"
label val move_coastal move_coastal
label var move_coastal "Direction of Move if Intentending to Move"
gen willmovefurther=(inrange(move_coastal,3,4))
label var willmovefurther "Intend to Move"
order willmovefurther, a(move_coastal)

replace cc_move="0" if cc_move=="No, makes me much less likely to move"
replace cc_move="1" if cc_move=="No, makes me somewhat less likely to move"
replace cc_move="2" if cc_move=="Does not affect my likelihood of moving"
replace cc_move="3" if cc_move=="Yes, makes me somwhat more likely to move"
replace cc_move="4" if cc_move=="Yes, makes me much more likely to move"
destring cc_move, replace
label define cc_move 0 "Less Likely to Move" 1 "Somewhat Less Likely to Move" 2 "Doesn't Affect Move Likelihood" 3 "Somewhat More Likely to Move" 4 "More Likely to Move"
label val cc_move cc_move
label var cc_move "Climate Change Impact on Intentions to Move"
gen willmoveclimate=(cc_move>=3)
label var willmoveclimate "Intend to Move Because of Climate Change"
order willmoveclimate, a(cc_move)
label var cc_move_open "Climate Change Impact on Intentions to Move (Text Response)"

replace climate_mig_1="0" if climate_mig_1=="Definitely agree"
replace climate_mig_1="1" if climate_mig_1=="Somewhat agree"
replace climate_mig_1="2" if climate_mig_1=="Neither agree nor disagree"
replace climate_mig_1="3" if climate_mig_1=="Somewhat disagree"
replace climate_mig_1="4" if climate_mig_1=="Definitely disagree"
destring climate_mig_1, replace
label define climate_mig_1 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val climate_mig_1 climate_mig_1
ren climate_mig_1 climatemig1
label var climatemig1 "Climate-driven migration is not a serious problem."
replace climate_mig_2="0" if climate_mig_2=="Definitely disagree"
replace climate_mig_2="1" if climate_mig_2=="Somewhat disagree"
replace climate_mig_2="2" if climate_mig_2=="Neither agree nor disagree"
replace climate_mig_2="3" if climate_mig_2=="Somewhat agree"
replace climate_mig_2="4" if climate_mig_2=="Definitely agree"
destring climate_mig_2, replace
label define climate_mig_2 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_mig_2 climate_mig_2
ren climate_mig_2 climatemig2
label var climatemig2 "Climate-driven migration will have a serious impact during my lifetime."
replace climate_mig_3="0" if climate_mig_3=="Definitely disagree"
replace climate_mig_3="1" if climate_mig_3=="Somewhat disagree"
replace climate_mig_3="2" if climate_mig_3=="Neither agree nor disagree"
replace climate_mig_3="3" if climate_mig_3=="Somewhat agree"
replace climate_mig_3="4" if climate_mig_3=="Definitely agree"
destring climate_mig_3, replace
label define climate_mig_3 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_mig_3 climate_mig_3
ren climate_mig_3 climatemig3
label var climatemig3 "I would vote for a politician who promised to take action to address climate-driven migration."
replace climate_mig_4="0" if climate_mig_4=="Definitely agree"
replace climate_mig_4="1" if climate_mig_4=="Somewhat agree"
replace climate_mig_4="2" if climate_mig_4=="Neither agree nor disagree"
replace climate_mig_4="3" if climate_mig_4=="Somewhat disagree"
replace climate_mig_4="4" if climate_mig_4=="Definitely disagree"
destring climate_mig_4, replace
label define climate_mig_4 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val climate_mig_4 climate_mig_4
ren climate_mig_4 climatemig4
label var climatemig4 "The U.S. should not do more to help climate-driven migrants."
replace climate_mig_5="0" if climate_mig_5=="Definitely disagree"
replace climate_mig_5="1" if climate_mig_5=="Somewhat disagree"
replace climate_mig_5="2" if climate_mig_5=="Neither agree nor disagree"
replace climate_mig_5="3" if climate_mig_5=="Somewhat agree"
replace climate_mig_5="4" if climate_mig_5=="Definitely agree"
destring climate_mig_5, replace
label define climate_mig_5 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_mig_5 climate_mig_5
ren climate_mig_5 climatemig5
label var climatemig5 "The international community should do more to help climate-driven migrants."
foreach x of var climatemig1 climatemig2 climatemig3 climatemig4 climatemig5 {
gen `x'_high=(`x'>=3)
order `x'_high, b(`x')
}
label var climatemig1_high "Climate-driven migration is not a serious problem."
label var climatemig2_high "Climate-driven migration will have a serious impact during my lifetime."
label var climatemig3_high "I would vote for a politician who promised to take action to address climate-driven migration."
label var climatemig4_high "The U.S. should not do more to help climate-driven migrants."
label var climatemig5_high "The international community should do more to help climate-driven migrants."

replace general_mig_1="0" if general_mig_1=="Definitely agree"
replace general_mig_1="1" if general_mig_1=="Somewhat agree"
replace general_mig_1="2" if general_mig_1=="Neither agree nor disagree"
replace general_mig_1="3" if general_mig_1=="Somewhat disagree"
replace general_mig_1="4" if general_mig_1=="Definitely disagree"
destring general_mig_1, replace
label define general_mig_1 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val general_mig_1 general_mig_1
ren general_mig_1 migration1
label var migration1 "Migration is not a serious problem."
replace general_mig_2="0" if general_mig_2=="Definitely disagree"
replace general_mig_2="1" if general_mig_2=="Somewhat disagree"
replace general_mig_2="2" if general_mig_2=="Neither agree nor disagree"
replace general_mig_2="3" if general_mig_2=="Somewhat agree"
replace general_mig_2="4" if general_mig_2=="Definitely agree"
destring general_mig_2, replace
label define general_mig_2 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val general_mig_2 general_mig_2
ren general_mig_2 migration2
label var migration2 "Migration will have a serious impact during my lifetime."
replace general_mig_3="0" if general_mig_3=="Definitely disagree"
replace general_mig_3="1" if general_mig_3=="Somewhat disagree"
replace general_mig_3="2" if general_mig_3=="Neither agree nor disagree"
replace general_mig_3="3" if general_mig_3=="Somewhat agree"
replace general_mig_3="4" if general_mig_3=="Definitely agree"
destring general_mig_3, replace
label define general_mig_3 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val general_mig_3 general_mig_3
ren general_mig_3 migration3
label var migration3 "I would vote for a politician who promised to take action to address migration."
replace general_mig_4="0" if general_mig_4=="Definitely agree"
replace general_mig_4="1" if general_mig_4=="Somewhat agree"
replace general_mig_4="2" if general_mig_4=="Neither agree nor disagree"
replace general_mig_4="3" if general_mig_4=="Somewhat disagree"
replace general_mig_4="4" if general_mig_4=="Definitely disagree"
destring general_mig_4, replace
label define general_mig_4 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val general_mig_4 migration4
ren general_mig_4 migration4
label var migration4 "The U.S. should not do more to help migrants."
replace general_mig_5="0" if general_mig_5=="Definitely disagree"
replace general_mig_5="1" if general_mig_5=="Somewhat disagree"
replace general_mig_5="2" if general_mig_5=="Neither agree nor disagree"
replace general_mig_5="3" if general_mig_5=="Somewhat agree"
replace general_mig_5="4" if general_mig_5=="Definitely agree"
destring general_mig_5, replace
label define general_mig_5 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val general_mig_5 general_mig_5
ren general_mig_5 migration5
label var migration5 "The international community should do more to help climate-driven migrants."
foreach x of var migration1 migration2 migration3 migration4 migration5 {
gen `x'_high=(`x'>=3)
order `x'_high, b(`x')
}
label var migration1_high "Migration is not a serious problem."
label var migration2_high "Migration will have a serious impact during my lifetime."
label var migration3_high "I would vote for a politician who promised to take action to address migration."
label var migration4_high "The U.S. should not do more to help migrants."
label var migration5_high "The international community should do more to help migrants."

replace climate_1="0" if climate_1=="Definitely Agree"
replace climate_1="1" if climate_1=="Somewhat Agree"
replace climate_1="2" if climate_1=="Neither Agree Nor Disagree"
replace climate_1="3" if climate_1=="Somewhat Disagree"
replace climate_1="4" if climate_1=="Definitely Disagree"
destring climate_1, replace
label define climate_1 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val climate_1 climate_1
ren climate_1 climatechg1
label var climatechg1 "Climate change is not a serious problem."
replace climate_2="0" if climate_2=="Definitely Disagree"
replace climate_2="1" if climate_2=="Somewhat Disagree"
replace climate_2="2" if climate_2=="Neither Agree Nor Disagree"
replace climate_2="3" if climate_2=="Somewhat Agree"
replace climate_2="4" if climate_2=="Definitely Agree"
destring climate_2, replace
label define climate_2 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_2 climate_2
ren climate_2 climatechg2
label var climatechg2 "Climate change will have a serious impact during my lifetime."
replace climate_3="0" if climate_3=="Definitely Disagree"
replace climate_3="1" if climate_3=="Somewhat Disagree"
replace climate_3="2" if climate_3=="Neither Agree Nor Disagree"
replace climate_3="3" if climate_3=="Somewhat Agree"
replace climate_3="4" if climate_3=="Definitely Agree"
destring climate_3, replace
label define climate_3 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_3 climate_3
ren climate_3 climatechg3
label var climatechg3 "I would vote for a politician who promised to take action to address climate change."
replace climate_5="0" if climate_5=="Definitely Agree"
replace climate_5="1" if climate_5=="Somewhat Agree"
replace climate_5="2" if climate_5=="Neither Agree Nor Disagree"
replace climate_5="3" if climate_5=="Somewhat Disagree"
replace climate_5="4" if climate_5=="Definitely Disagree"
destring climate_5, replace
label define climate_5 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val climate_5 climate_5
ren climate_5 climatechg4
order climatechg4, b(climate_4)
label var climatechg4 "The U.S. should not do more to reduce climate change."
replace climate_6="0" if climate_6=="Definitely Disagree"
replace climate_6="1" if climate_6=="Somewhat Disagree"
replace climate_6="2" if climate_6=="Neither Agree Nor Disagree"
replace climate_6="3" if climate_6=="Somewhat Agree"
replace climate_6="4" if climate_6=="Definitely Agree"
destring climate_6, replace
label define climate_6 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_6 climate_6
ren climate_6 climatechg5
order climatechg5, b(climate_4)
label var climatechg5 "The international community should do more to reduce climate change."
replace climate_4="0" if climate_4=="Definitely Disagree"
replace climate_4="1" if climate_4=="Somewhat Disagree"
replace climate_4="2" if climate_4=="Neither Agree Nor Disagree"
replace climate_4="3" if climate_4=="Somewhat Agree"
replace climate_4="4" if climate_4=="Definitely Agree"
destring climate_4, replace
label define climate_4 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_4 climate_4
ren climate_4 climatechg6
label var climatechg6 "I would personally support a tax increase to fund national programs to reduce climate change."
foreach x of var climatechg1 climatechg2 climatechg3 climatechg4 climatechg5 climatechg6 {
gen `x'_high=(`x'>=3)
order `x'_high, b(`x')
}
label var climatechg1_high "Climate change is not a serious problem."
label var climatechg2_high "Climate change will have a serious impact during my lifetime."
label var climatechg3_high "I would vote for a politician who promised to take action to reduce climate change."
label var climatechg4_high "The U.S. should not do more to reduce climate change."
label var climatechg5_high "The international community should do more to reduce climate change."
label var climatechg6_high "I would personally support a tax increase to fund national programs to reduce climate change."

replace climate_7="0" if climate_7=="Definitely Disagree"
replace climate_7="1" if climate_7=="Somewhat Disagree"
replace climate_7="2" if climate_7=="Neither Agree Nor Disagree"
replace climate_7="3" if climate_7=="Somewhat Agree"
replace climate_7="4" if climate_7=="Definitely Agree"
destring climate_7, replace
label define climate_7 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_7 climate_7
ren climate_7 anthropogenic
label var anthropogenic "Human activities are the main cause of climate change."
gen anthropogenic_agree=(anthropogenic>=3)
order anthropogenic_agree, a(anthropogenic)
label var anthropogenic_agree "Agree Humans Cause Climate Change"

replace climate_8="0" if climate_8=="Definitely Disagree"
replace climate_8="1" if climate_8=="Somewhat Disagree"
replace climate_8="2" if climate_8=="Neither Agree Nor Disagree"
replace climate_8="3" if climate_8=="Somewhat Agree"
replace climate_8="4" if climate_8=="Definitely Agree"
destring climate_8, replace
label define climate_8 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_8 climate_8
ren climate_8 hurricane_cause
label var hurricane_cause "Hurricanes are caused by climate change."
gen hurricane_cause_agree=(hurricane_cause>=3)
order hurricane_cause_agree, a(hurricane_cause)
label var hurricane_cause_agree "Agree Climate Change Causes Hurricanes"
replace climate_9="0" if climate_9=="Definitely Disagree"
replace climate_9="1" if climate_9=="Somewhat Disagree"
replace climate_9="2" if climate_9=="Neither Agree Nor Disagree"
replace climate_9="3" if climate_9=="Somewhat Agree"
replace climate_9="4" if climate_9=="Definitely Agree"
destring climate_9, replace
label define climate_9 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_9 climate_9
ren climate_9 hurricane_worse
label var hurricane_worse "Hurricanes are worsened by climate change."
gen hurricane_worse_agree=(hurricane_worse>=3)
order hurricane_worse_agree, a(hurricane_worse)
label var hurricane_worse_agree "Agree Climate Change Worsens Hurricanes"

replace cc_costs_1="0" if cc_costs_1=="$0 "
replace cc_costs_1="1" if cc_costs_1=="$1-$49"
replace cc_costs_1="2" if cc_costs_1=="$50-99"
replace cc_costs_1="3" if cc_costs_1=="$100 or greater"
destring cc_costs_1, replace
label define cc_costs_1 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_1 cc_costs_1
ren cc_costs_1 tax_migjob
label var tax_migjob "Tax Increase to Fund: Migrant Job Training"
replace cc_costs_2="0" if cc_costs_2=="$0 "
replace cc_costs_2="1" if cc_costs_2=="$1-$49"
replace cc_costs_2="2" if cc_costs_2=="$50-99"
replace cc_costs_2="3" if cc_costs_2=="$100 or greater"
destring cc_costs_2, replace
label define cc_costs_2 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_2 cc_costs_2
ren cc_costs_2 tax_border
label var tax_border "Tax Increase to Fund: Border Security"
replace cc_costs_3="0" if cc_costs_3=="$0 "
replace cc_costs_3="1" if cc_costs_3=="$1-$49"
replace cc_costs_3="2" if cc_costs_3=="$50-99"
replace cc_costs_3="3" if cc_costs_3=="$100 or greater"
destring cc_costs_3, replace
label define cc_costs_3 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_3 cc_costs_3
ren cc_costs_3 tax_usclimmig
label var tax_usclimmig "Tax Increase to Fund: Resettle Internal Climate Migrants"
replace cc_costs_4="0" if cc_costs_4=="$0 "
replace cc_costs_4="1" if cc_costs_4=="$1-$49"
replace cc_costs_4="2" if cc_costs_4=="$50-99"
replace cc_costs_4="3" if cc_costs_4=="$100 or greater"
destring cc_costs_4, replace
label define cc_costs_4 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_4 cc_costs_4
ren cc_costs_4 tax_intlclimmig
label var tax_intlclimmig "Tax Increase to Fund: Resettle International Climate Migrants"
replace cc_costs_5="0" if cc_costs_5=="$0 "
replace cc_costs_5="1" if cc_costs_5=="$1-$49"
replace cc_costs_5="2" if cc_costs_5=="$50-99"
replace cc_costs_5="3" if cc_costs_5=="$100 or greater"
destring cc_costs_5, replace
label define cc_costs_5 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_5 cc_costs_5
ren cc_costs_5 tax_carbon
label var tax_carbon "Tax Increase to Fund: Carbon Tax"
replace cc_costs_6="0" if cc_costs_6=="$0 "
replace cc_costs_6="1" if cc_costs_6=="$1-$49"
replace cc_costs_6="2" if cc_costs_6=="$50-99"
replace cc_costs_6="3" if cc_costs_6=="$100 or greater"
destring cc_costs_6, replace
label define cc_costs_6 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_6 cc_costs_6
ren cc_costs_6 tax_cleanenergy
label var tax_cleanenergy "Tax Increase to Fund: Clean Energy"
replace cc_costs_7="0" if cc_costs_7=="$0 "
replace cc_costs_7="1" if cc_costs_7=="$1-$49"
replace cc_costs_7="2" if cc_costs_7=="$50-99"
replace cc_costs_7="3" if cc_costs_7=="$100 or greater"
destring cc_costs_7, replace
label define cc_costs_7 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_7 cc_costs_7
ren cc_costs_7 tax_minrestrict
label var tax_minrestrict "Tax Increase to Fund: Restrictions on Oil/Coal"
replace cc_costs_8="0" if cc_costs_8=="$0 "
replace cc_costs_8="1" if cc_costs_8=="$1-$49"
replace cc_costs_8="2" if cc_costs_8=="$50-99"
replace cc_costs_8="3" if cc_costs_8=="$100 or greater"
destring cc_costs_8, replace
label define cc_costs_8 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_8 cc_costs_8
ren cc_costs_8 tax_milclim
label var tax_milclim "Tax Increase to Fund: Protecting Military from Climate Change"
replace cc_costs_9="0" if cc_costs_9=="$0 "
replace cc_costs_9="1" if cc_costs_9=="$1-$49"
replace cc_costs_9="2" if cc_costs_9=="$50-99"
replace cc_costs_9="3" if cc_costs_9=="$100 or greater"
destring cc_costs_9, replace
label define cc_costs_9 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_9 cc_costs_9
ren cc_costs_9 tax_fueleff
label var tax_fueleff "Tax Increase to Fund: Fuel Efficiency Standards"
replace cc_costs_10="0" if cc_costs_10=="$0 "
replace cc_costs_10="1" if cc_costs_10=="$1-$49"
replace cc_costs_10="2" if cc_costs_10=="$50-99"
replace cc_costs_10="3" if cc_costs_10=="$100 or greater"
destring cc_costs_10, replace
label define cc_costs_10 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_10 cc_costs_10
ren cc_costs_10 tax_coast
label var tax_coast "Tax Increase to Fund: Coastal Protection"
replace cc_costs_11="0" if cc_costs_11=="$0 "
replace cc_costs_11="1" if cc_costs_11=="$1-$49"
replace cc_costs_11="2" if cc_costs_11=="$50-99"
replace cc_costs_11="3" if cc_costs_11=="$100 or greater"
destring cc_costs_11, replace
label define cc_costs_11 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_11 cc_costs_11
ren cc_costs_11 tax_flood
label var tax_flood "Tax Increase to Fund: Flood Retrofitting"
replace cc_costs_12="0" if cc_costs_12=="$0 "
replace cc_costs_12="1" if cc_costs_12=="$1-$49"
replace cc_costs_12="2" if cc_costs_12=="$50-99"
replace cc_costs_12="3" if cc_costs_12=="$100 or greater"
destring cc_costs_12, replace
label define cc_costs_12 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_12 cc_costs_12
ren cc_costs_12 tax_streetpump
label var tax_streetpump "Tax Increase to Fund: Raising Streets/Building Pumping Stations"
replace cc_costs_13="0" if cc_costs_13=="$0 "
replace cc_costs_13="1" if cc_costs_13=="$1-$49"
replace cc_costs_13="2" if cc_costs_13=="$50-99"
replace cc_costs_13="3" if cc_costs_13=="$100 or greater"
destring cc_costs_13, replace
label define cc_costs_13 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_13 cc_costs_13
ren cc_costs_13 tax_windows
label var tax_windows "Tax Increase to Fund: Weather-Proofed Windows"
foreach x of var tax_* {
gen `x'_any=(`x'>0)
order `x'_any, b(`x')
}
label var tax_migjob_any "Tax Increase to Fund: Migrant Job Training"
label var tax_border_any "Tax Increase to Fund: Border Security"
label var tax_usclimmig_any "Tax Increase to Fund: Resettle Internal Climate Migrants"
label var tax_intlclimmig_any "Tax Increase to Fund: Resettle International Climate Migrants"
label var tax_carbon_any "Tax Increase to Fund: Carbon Tax"
label var tax_cleanenergy_any "Tax Increase to Fund: Clean Energy"
label var tax_minrestrict_any "Tax Increase to Fund: Restrictions on Oil/Coal"
label var tax_milclim_any "Tax Increase to Fund: Protecting Military from Climate Change"
label var tax_fueleff_any "Tax Increase to Fund: Fuel Efficiency Standards"
label var tax_coast_any "Tax Increase to Fund: Coastal Protection"
label var tax_flood_any "Tax Increase to Fund: Flood Retrofitting"
label var tax_streetpump_any "Tax Increase to Fund: Raising Streets/Building Pumping Stations"
label var tax_windows_any "Tax Increase to Fund: Weather-Proofed Windows"

gen implement_migjob=(cc_implementation_5!="")
label var implement_migjob "Locality Implemented: Migrant Job Training"
drop cc_implementation_4 cc_implementation_5
gen implement_border=(cc_implementation_8!="")
label var implement_border "Locality Implemented: Border Security"
drop cc_implementation_8
gen implement_usclimmig=(cc_implementation_13!="")
label var implement_usclimmig "Locality Implemented: Resettle Internal Climate Migrants"
drop cc_implementation_13
gen implement_intlclimmig=(cc_implementation_14!="")
label var implement_intlclimmig "Locality Implemented: Resettle International Climate Migrants"
drop cc_implementation_14
gen implement_carbon=(cc_implementation_16!="")
label var implement_carbon "Locality Implemented: Carbon Tax"
drop cc_implementation_16
gen implement_cleanenergy=(cc_implementation_15!="")
label var implement_cleanenergy "Locality Implemented: Clean Energy"
drop cc_implementation_15
gen implement_minrestrict=(cc_implementation_17!="")
label var implement_minrestrict "Locality Implemented: Restrictions on Oil/Coal"
drop cc_implementation_17
gen implement_milclim=(cc_implementation_18!="")
label var implement_milclim "Locality Implemented: Protecting Military from Climate Change"
drop cc_implementation_18
gen implement_fueleff=(cc_implementation_20!="")
label var implement_fueleff "Locality Implemented: Fuel Efficiency Standards"
drop cc_implementation_20
gen implement_coast=(cc_implementation_21!="")
label var implement_coast "Locality Implemented: Coastal Protection"
drop cc_implementation_21
gen implement_flood=(cc_implementation_22!="")
label var implement_flood "Locality Implemented: Flood Retrofitting"
drop cc_implementation_22
gen implement_streetpump=(cc_implementation_23!="")
label var implement_streetpump "Locality Implemented: Raising Streets/Building Pumping Stations"
drop cc_implementation_23
gen implement_windows=(cc_implementation_24!="")
label var implement_windows "Locality Implemented: Weather-Proofed Windows"
drop cc_implementation_24
order implement_migjob implement_border implement_usclimmig implement_intlclimmig implement_carbon implement_cleanenergy implement_minrestrict implement_milclim implement_fueleff implement_coast implement_flood implement_streetpump implement_windows, a(tax_windows)

replace rel_import_scale_1="0" if rel_import_scale_1=="Not a priority at all"
replace rel_import_scale_1="1" if rel_import_scale_1=="Slight priority"
replace rel_import_scale_1="2" if rel_import_scale_1=="Medium level priority"
replace rel_import_scale_1="3" if rel_import_scale_1=="Fairly high priority"
replace rel_import_scale_1="4" if rel_import_scale_1=="Top priority"
destring rel_import_scale_1, replace
label define rel_import_scale_1 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_1 rel_import_scale_1
ren rel_import_scale_1 priority_climchg
label var priority_climchg "Priority: Addressing Climate Change"
replace rel_import_scale_2="0" if rel_import_scale_2=="Not a priority at all"
replace rel_import_scale_2="1" if rel_import_scale_2=="Slight priority"
replace rel_import_scale_2="2" if rel_import_scale_2=="Medium level priority"
replace rel_import_scale_2="3" if rel_import_scale_2=="Fairly high priority"
replace rel_import_scale_2="4" if rel_import_scale_2=="Top priority"
destring rel_import_scale_2, replace
label define rel_import_scale_2 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_2 rel_import_scale_2
ren rel_import_scale_2 priority_climmig
label var priority_climmig "Priority: Addressing Climate Migration"
replace rel_import_scale_3="0" if rel_import_scale_3=="Not a priority at all"
replace rel_import_scale_3="1" if rel_import_scale_3=="Slight priority"
replace rel_import_scale_3="2" if rel_import_scale_3=="Medium level priority"
replace rel_import_scale_3="3" if rel_import_scale_3=="Fairly high priority"
replace rel_import_scale_3="4" if rel_import_scale_3=="Top priority"
destring rel_import_scale_3, replace
label define rel_import_scale_3 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_3 rel_import_scale_3
ren rel_import_scale_3 priority_migration
label var priority_migration "Priority: Addressing Migration"
replace rel_import_scale_4="0" if rel_import_scale_4=="Not a priority at all"
replace rel_import_scale_4="1" if rel_import_scale_4=="Slight priority"
replace rel_import_scale_4="2" if rel_import_scale_4=="Medium level priority"
replace rel_import_scale_4="3" if rel_import_scale_4=="Fairly high priority"
replace rel_import_scale_4="4" if rel_import_scale_4=="Top priority"
destring rel_import_scale_4, replace
label define rel_import_scale_4 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_4 rel_import_scale_4
ren rel_import_scale_4 priority_economy
label var priority_economy "Priority: Strengthening Economy"
replace rel_import_scale_5="0" if rel_import_scale_5=="Not a priority at all"
replace rel_import_scale_5="1" if rel_import_scale_5=="Slight priority"
replace rel_import_scale_5="2" if rel_import_scale_5=="Medium level priority"
replace rel_import_scale_5="3" if rel_import_scale_5=="Fairly high priority"
replace rel_import_scale_5="4" if rel_import_scale_5=="Top priority"
destring rel_import_scale_5, replace
label define rel_import_scale_5 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_5 rel_import_scale_5
ren rel_import_scale_5 priority_health
label var priority_health "Priority: Improving Healthcare System"
replace rel_import_scale_6="0" if rel_import_scale_6=="Not a priority at all"
replace rel_import_scale_6="1" if rel_import_scale_6=="Slight priority"
replace rel_import_scale_6="2" if rel_import_scale_6=="Medium level priority"
replace rel_import_scale_6="3" if rel_import_scale_6=="Fairly high priority"
replace rel_import_scale_6="4" if rel_import_scale_6=="Top priority"
destring rel_import_scale_6, replace
label define rel_import_scale_6 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_6 rel_import_scale_6
ren rel_import_scale_6 priority_military
label var priority_military "Priority: Strengthening Military"
foreach x of var priority_* {
gen `x'_high=(`x'>=3)
order `x'_high, b(`x')
}
label var priority_climchg_high "Priority: Addressing Climate Change"
label var priority_climmig_high "Priority: Addressing Climate Migration"
label var priority_migration_high "Priority: Addressing Migration"
label var priority_economy_high "Priority: Strengthening Economy"
label var priority_health_high "Priority: Improving Healthcare System"
label var priority_military_high "Priority: Strengthening Military"

swindex priority_climmig_high climatemig1_high climatemig2_high, gen(climmig_importance)
label var climmig_importance "Climate Migration Importance Index"
swindex climatemig3_high climatemig4_high climatemig5_high tax_usclimmig_any tax_intlclimmig_any, gen(climmig_action)
label var climmig_action "Climate Migration Action Index"
swindex priority_climchg_high climatechg1_high climatechg2_high, gen(climchg_importance)
label var climchg_importance "Climate Change Importance Index"
swindex climatechg3_high climatechg4_high climatechg5_high climatechg6_high, gen(climchg_action)
label var climchg_action "Climate Change Action Index"
order climmig_importance climmig_action climchg_importance climchg_action, a(priority_military)
swindex tax_milclim_any tax_coast_any tax_flood_any tax_streetpump_any tax_windows_any, gen(climchg_adaptation)
label var climchg_adaptation "Climate Change Adaptation Index"
swindex tax_carbon_any tax_cleanenergy_any tax_minrestrict_any tax_fueleff_any, gen(climchg_mitigation)
label var climchg_mitigation "Climate Change Mitigation Index"
swindex anthropogenic_agree hurricane_cause_agree hurricane_worse_agree, gen(climchg_science)
label var climchg_science "Climate Change Science Index"
order climchg_mitigation climchg_adaptation climchg_science, a(climchg_action)

factor priority_climmig_high climatemig1_high climatemig2_high, pcf
rotate, promax
predict climmig_importance_pcf
label var climmig_importance_pcf "Climate Migration Importance Index (PCF)"
gen climmig_importance_ew=(priority_climmig_high+climatemig1_high+climatemig2_high)/3
label var climmig_importance_ew "Climate Migration Importance Index (EW)"
order climmig_importance_pcf climmig_importance_ew, a(climmig_importance)

factor climatemig3_high climatemig4_high climatemig5_high tax_usclimmig_any tax_intlclimmig_any, pcf
rotate, promax
predict climmig_action_pcf
label var climmig_action_pcf "Climate Migration Action Index (PCF)"
gen climmig_action_ew=(climatemig3_high+climatemig4_high+climatemig5_high+tax_usclimmig_any+tax_intlclimmig_any)/5
label var climmig_action_ew "Climate Migration Action Index (EW)"
order climmig_action_pcf climmig_action_ew, a(climmig_action)

factor priority_climchg_high climatechg1_high climatechg2_high, pcf
rotate, promax
predict climchg_importance_pcf
label var climchg_importance_pcf "Climate Change Importance Index (PCF)"
gen climchg_importance_ew=(priority_climchg_high+climatechg1_high+climatechg2_high)/3
label var climchg_importance_ew "Climate Change Importance Index (EW)"
order climchg_importance_pcf climchg_importance_ew, a(climchg_importance)

factor climatechg3_high climatechg4_high climatechg5_high climatechg6_high, pcf
rotate, promax
predict climchg_action_pcf
label var climchg_action_pcf "Climate Change Action Index (PCF)"
gen climchg_action_ew=(climatechg3_high+climatechg4_high+climatechg5_high+climatechg6_high)/4
label var climchg_action_ew "Climate Change Action Index (EW)"
order climchg_action_pcf climchg_action_ew, a(climchg_action)

factor tax_milclim_any tax_coast_any tax_flood_any tax_streetpump_any tax_windows_any, pcf
rotate, promax
predict climchg_adaptation_pcf
label var climchg_adaptation_pcf "Climate Change Adaptation Index (PCF)"
gen climchg_adaptation_ew=(tax_milclim_any+tax_coast_any+tax_flood_any+tax_streetpump_any+tax_windows_any)/5
label var climchg_adaptation_ew "Climate Change Adaptation Index (EW)"
order climchg_adaptation_pcf climchg_adaptation_ew, a(climchg_adaptation)

factor tax_carbon_any tax_cleanenergy_any tax_minrestrict_any tax_fueleff_any, pcf
rotate, promax
predict climchg_mitigation_pcf
label var climchg_mitigation_pcf "Climate Change Mitigation Index (PCF)"
gen climchg_mitigation_ew=(tax_carbon_any+tax_cleanenergy_any+tax_minrestrict_any+tax_fueleff_any)/4
label var climchg_mitigation_ew "Climate Change Mitigation Index (EW)"
order climchg_mitigation_pcf climchg_mitigation_ew, a(climchg_mitigation)

factor anthropogenic_agree hurricane_cause_agree hurricane_worse_agree, pcf
rotate, promax
predict climchg_science_pcf
label var climchg_science_pcf "Climate Change Science Index (PCF)"
gen climchg_science_ew=(anthropogenic_agree+hurricane_cause_agree+hurricane_worse_agree)/3
label var climchg_science_ew "Climate Change Science Index (EW)"
order climchg_science_pcf climchg_science_ew, a(climchg_science)

foreach x of var climmig_importance_ew climmig_action_ew climchg_importance_ew climchg_action_ew climchg_adaptation_ew climchg_mitigation_ew climchg_science_ew {
egen `x'_std=std(`x')
replace `x'=`x'_std
drop `x'_std
}

********************************************************************************
*								CREATE POPWEIGHTS							   *
********************************************************************************

gen plus65=(age>=65)
gen plushs=(education>=1)
gen pluscollege=(education>=4)
ebalance plus65 woman race_white race_black race_indigenous race_asian race_latinx race_multi plushs pluscollege republican democrat, manualtargets(.168 .505 .758 .136 .016 .061 .189 .029 .889 .337 .470 .420)
ren _webal eweight
label var eweight "Entropy Weights"

ebalance plus65 woman race_white race_black race_indigenous race_asian race_latinx race_multi plushs pluscollege republican democrat, manualtargets(.15825 .513 .5225 .19025 .00425 .03225 .2075 .04375 .879 .319 .395 .425)
drop plus65 plushs pluscollege
ren _webal rweight
label var rweight "Entropy Weights -- 4 States"

sort respondent_id
save "${data}/Survey/survey_final.dta", replace

********************************************************************************
*								ADD CLIMATE DATA							   *
********************************************************************************

replace obsdrop=1 if latitude==10 & longitude==8
replace obsdrop=1 if respondent_id==1311
replace obsdrop=1 if respondent_id==1501
replace obsdrop=1 if respondent_id==1523
replace obsdrop=1 if respondent_id==1584
replace obsdrop=1 if respondent_id==1588
replace obsdrop=1 if respondent_id==1847
replace obsdrop=1 if respondent_id==2049
replace obsdrop=1 if respondent_id==1518
replace obsdrop=1 if respondent_id==1534
replace obsdrop=1 if respondent_id==3334
replace geoid=17031 if respondent_id==1608
replace statefp=17 if respondent_id==1608
replace countyfp=031 if respondent_id==1608
replace state="Illinois" if respondent_id==1608
replace county="Cook" if respondent_id==1608
replace geoid=17031 if respondent_id==2289
replace statefp=17 if respondent_id==2289
replace countyfp=031 if respondent_id==2289
replace state="Illinois" if respondent_id==2289
replace county="Cook" if respondent_id==2289
replace geoid=12127 if respondent_id==2344
replace statefp=12 if respondent_id==2344
replace countyfp=127 if respondent_id==2344
replace state="Florida" if respondent_id==2344
replace county="Volusia" if respondent_id==2344

gen focalsample1=(state=="Florida" | state=="Louisiana" | state=="Texas")
label var focalsample1 "PAP Sample"
gen focalsample2=(state=="Florida" | state=="Louisiana" | state=="Texas" | state=="North Carolina")
label var focalsample2 "PAP Sample + NC"
replace obsdrop=1 if focalsample2==0
order focalsample1 focalsample2, a(priority_military)

gen post=(start_date>=22916)
label var post "Post-Hurricane Ian Landfall"
gen time2ian=start_date-22916
label var time2ian "Days Relative to Hurricane Ian Landfall"
gen postwave=(wave>=6)
label var postwave "Post-Hurricane Ian Landfall Wave"
gen wave2ian=wave-6
label var wave2ian "Waves Relative to Hurricane Ian Landfall"
gen postdynamic=0
replace postdynamic=1 if start_date>=22916 & state=="Florida"
replace postdynamic=1 if start_date>=22921 & state=="North Carolina"
label var postdynamic "Post-Hurricane Ian Landfall"
order postdynamic, a(post)
gen time2ian_dynamic=time2ian
replace time2ian_dynamic=start_date-22921 if state=="North Carolina"
label var time2ian_dynamic "Days Relative to Hurricane Ian Landfall"
order time2ian_dynamic, a(time2ian)

merge m:1 geoid using "${data}/Hurricane/ian_geo.dta"
drop if _m==2
drop regcomm
gen i_ian_deaths=(ian_deaths>0)
order i_ian_deaths, b(ian_deaths)
label var i_ian_deaths "Hurricane Ian Deaths (=1)"
replace i_ian_deaths=. if _m==1
drop _m
egen std_ian_death=std(ian_death)
label var std_ian_death "Hurricane Ian Deaths"
replace std_ian_death=. if i_ian_deaths==.
order std_ian_death, a(ian_deaths)
sort respondent_id

replace ian_windswath34=1 if ian_windswath64==1
replace ian_windswath50=1 if ian_windswath64==1
replace ian_windswath34=1 if ian_windswath50==1
label var ian_windswath34 "Hurricane Ian Tropical Storm-Force Windswath"
label var ian_windswath50 "Hurricane Ian Storm-Force Windswath"
label var ian_windswath64 "Hurricane Ian Hurricane-Force Windswath"

gen ian_windswath=0
replace ian_windswath=. if ian_windswath34==.
replace ian_windswath=1 if ian_windswath34==1
replace ian_windswath=2 if ian_windswath50==1
replace ian_windswath=2 if ian_windswath64==1
label var ian_windswath "Hurricane Ian Binary Windswath"
label define wind 0 "None" 1 "Tropical Storm" 2 "Storm"
label val ian_windswath wind
order ian_windswath, a(ian_windswath64)

gen ian_windswath2=0
replace ian_windswath2=. if ian_windswath34==.
replace ian_windswath2=1 if ian_windswath34==1
replace ian_windswath2=2 if ian_windswath50==1
replace ian_windswath2=3 if ian_windswath64==1
label var ian_windswath2 "Hurricane Ian Maximum Windswath"
label define windswath 0 "None" 1 "Tropical Storm" 2 "Storm" 3 "Hurricane"
label val ian_windswath2 windswath
order ian_windswath2, a(ian_windswath)

gen ian_cyclonic=(ian_windswath>0)
replace ian_cyclonic=. if ian_windswath==.
label var ian_cyclonic "Hurricane Ian Cyclonic Winds"
order ian_cyclonic, b(ian_windswath)

gen ian_distance_mi=((ian_distance)*111)*0.621371
order ian_distance_mi, a(ian_distance)
label var ian_distance_mi "Distance to Hurricane Ian Eyepath"

gen ian_proximity=1/ian_distance_mi
order ian_proximity, b(ian_distance)
label var ian_proximity "Hurricane Ian Proximity to Eyepath"
egen std_ian_proximity=std(ian_proximity)
order std_ian_proximity, b(ian_proximity)
label var std_ian_proximity "Hurricane Ian Proximity to Eyepath"
gen ian_prox1=(ian_distance_mi<=10)
label var ian_prox1 "Proximity to Eyepath: 0-10 Miles"
gen ian_prox2=(ian_distance_mi>10 & ian_distance_mi<=25)
label var ian_prox2 "Proximity to Eyepath: 10-25 Miles"
gen ian_prox3=(ian_distance_mi>25 & ian_distance_mi<=50)
label var ian_prox3 "Proximity to Eyepath: 25-50 Miles"
gen ian_prox4=(ian_distance_mi>50 & ian_distance_mi<=75)
label var ian_prox4 "Proximity to Eyepath: 50-75 Miles"
gen ian_prox5=(ian_distance_mi>75 & ian_distance_mi<=100)
label var ian_prox5 "Proximity to Eyepath: 75-100 Miles"
gen ian_prox6=(ian_distance_mi>100 & ian_distance_mi<=500)
label var ian_prox6 "Proximity to Eyepath: 100-500 Miles"
order ian_prox1-ian_prox6, a(ian_proximity)
foreach x of var ian_prox1-ian_prox6 {
replace `x'=. if ian_distance==.
}

gen i_ian_surge=(ian_surge>=1)
replace i_ian_surge=. if ian_surge==.
order i_ian_surge, a(ian_surge)
label var i_ian_surge  "Hurricane Ian Storm Surge (=1)"
order ian_surge i_ian_surge, a(ian_evacuation)

gen ian_eyepath_broad=ian_eyepath
replace ian_eyepath_broad=1 if geoid==12081 | geoid==12027 | geoid==12055 | geoid==37153 | geoid==12049 | geoid==37167 | geoid==37123 | geoid==12095 | geoid==37125 | geoid==12043 | geoid==12097 | geoid==37037 | geoid==37007 | geoid==12071 | geoid==12115 | geoid==37047 | geoid==12009 | geoid==12105 | geoid==37093 | geoid==37165 | geoid==12093 | geoid==12015 | geoid==12061 | geoid==12127 | geoid==37155 | geoid==37151
label var ian_eyepath_broad "Hurricane Ian Eyepath + 26mi Buffer"
order ian_eyepath_broad, a(ian_eyepath)

sort respondent_id
save "${data}/Survey/survey_final.dta", replace

import delimited "${data}/Hurricane/ian_waze.csv", clear

gen ian_waze=1
collapse (sum) ian_waze, by(geoid)
tempfile waze
save `waze'

use "${data}/Survey/survey_final.dta", clear

merge m:1 geoid using `waze'
drop if _m==2
replace ian_waze=0 if state=="Florida" & _m==1
replace ian_waze=0 if (state=="Texas" | state=="Louisiana") & _m==1
replace ian_waze=. if state=="North Carolina" & _m==1
label var ian_waze "Hurricane Ian Road Incidents"
gen i_ian_waze=(ian_waze>0)
order i_ian_waze, b(ian_waze)
label var i_ian_waze "Hurricane Ian Road Incident (=1)"
replace i_ian_waze=. if ian_waze==.
order i_ian_waze ian_waze, a(fema_aid)
drop _m

gen i_fema_aid=(fema_aid>=1)
label var i_fema_aid "Hurricane Ian FEMA Assistance (=1)"
order i_fema_aid, b(fema_aid)
gen indiv_fema_aid=(fema_aid>=3)
label var indiv_fema_aid "Hurricane Ian FEMA Individual Assistance (=1)"
order indiv_fema_aid, a(fema_aid)

order emg_command, a(statefp)

swindex ian_surge ian_windswath ian_eyepath, gen(hurricane_index1)
label var hurricane_index1 "Hurricane Exposure Index"
swindex ian_surge ian_windswath ian_eyepath ian_evacuation ian_deaths, gen(hurricane_index2)
label var hurricane_index2 "Hurricane Exposure Index"
replace hurricane_index1=. if ian_surge==.
replace hurricane_index2=. if ian_surge==.

gen binary_index1=(hurricane_index1>-.6112757)
label var binary_index1 "Hurricane Exposure Index (=1)"
order binary_index1, a(hurricane_index1)

gen estsample=(focalsample2==1 & inrange(duration,240,1200) & inrange(age,18,99))
label var estsample "Estimation Sample"

compress
sort respondent_id
save "${data}/Survey/survey_final.dta", replace

merge m:1 geoid using "${data}/Hurricane/ida_geo.dta"
drop if _m==2
drop _m
sort respondent_id

replace ida_windswath34=1 if ida_windswath64==1
replace ida_windswath50=1 if ida_windswath64==1
replace ida_windswath34=1 if ida_windswath50==1
label var ida_windswath34 "Hurricane Ida Tropical Storm-Force Windswath"
label var ida_windswath50 "Hurricane Ida Storm-Force Windswath"
label var ida_windswath64 "Hurricane Ida Hurricane-Force Windswath"

gen ida_windswath=0
replace ida_windswath=. if focalsample2==0
replace ida_windswath=1 if ida_windswath34==1
replace ida_windswath=2 if ida_windswath50==1
replace ida_windswath=2 if ida_windswath64==1
label var ida_windswath "Hurricane Ida Binary Windswath"
label val ida_windswath wind
order ida_windswath, a(ida_windswath64)

gen ida_windswath2=0
replace ida_windswath2=. if focalsample2==0
replace ida_windswath2=1 if ida_windswath34==1
replace ida_windswath2=2 if ida_windswath50==1
replace ida_windswath2=3 if ida_windswath64==1
label var ida_windswath2 "Hurricane Ida Maximum Windswath"
label val ida_windswath2 windswath
order ida_windswath2, a(ida_windswath)

gen ida_cyclonic=(ida_windswath>0)
replace ida_cyclonic=. if ida_windswath==.
label var ida_cyclonic "Hurricane Ida Cyclonic Winds"
order ida_cyclonic, b(ida_windswath)

foreach x of var ida_windswath34 ida_windswath50 ida_windswath64 ida_cyclonic ida_windswath ida_windswath2 {
replace `x'=. if focalsample2==0
}

replace ida_eyepath=. if focalsample2==0
gen ida_distance_mi=((ida_distance)*111)*0.621371
order ida_distance_mi, a(ida_distance)
label var ida_distance_mi "Distance to Hurricane Ida Eyepath"

gen ida_proximity=1/ida_distance_mi
order ida_proximity, b(ida_distance)
label var ida_proximity "Hurricane Ida Proximity to Eyepath"
egen std_ida_proximity=std(ida_proximity)
order std_ida_proximity, b(ida_proximity)
label var std_ida_proximity "Hurricane Ida Proximity to Eyepath"

replace ida_surge=. if focalsample2==0
gen i_ida_surge=(ida_surge>=1)
replace i_ida_surge=. if ida_surge==.
order i_ida_surge, a(ida_surge)
label var i_ida_surge  "Hurricane Ida Storm Surge (=1)"
order ida_surge i_ida_surge, a(ida_windswath2)

sort respondent_id
save "${data}/Survey/survey_final.dta", replace

swindex ida_surge ida_windswath ida_eyepath, gen(ida_index1)
label var ida_index1 "Hurricane Ida Exposure Index"

gen binary_idaindex1=(ida_index1>-.3237408)
label var binary_idaindex1 "Hurricane Ida Exposure Index (=1)"
order binary_idaindex1, a(ida_index1)

compress
sort respondent_id
save "${data}/Survey/survey_final.dta", replace

merge m:1 geoid using "${data}/Hurricane/nicole_geo.dta"
drop if _m==2
drop _m
sort respondent_id

replace nicole_windswath34=1 if nicole_windswath64==1
replace nicole_windswath50=1 if nicole_windswath64==1
replace nicole_windswath34=1 if nicole_windswath50==1
label var nicole_windswath34 "Hurricane Nicole Tropical Storm-Force Windswath"
label var nicole_windswath50 "Hurricane Nicole Storm-Force Windswath"
label var nicole_windswath64 "Hurricane Nicole Hurricane-Force Windswath"

gen nicole_windswath=0
replace nicole_windswath=. if focalsample2==0
replace nicole_windswath=1 if nicole_windswath34==1
replace nicole_windswath=2 if nicole_windswath50==1
replace nicole_windswath=2 if nicole_windswath64==1
label var nicole_windswath "Hurricane Nicole Binary Windswath"
label val nicole_windswath wind
order nicole_windswath, a(nicole_windswath64)

gen nicole_windswath2=0
replace nicole_windswath2=. if focalsample2==0
replace nicole_windswath2=1 if nicole_windswath34==1
replace nicole_windswath2=2 if nicole_windswath50==1
replace nicole_windswath2=3 if nicole_windswath64==1
label var nicole_windswath2 "Hurricane Nicole Maximum Windswath"
label val nicole_windswath2 windswath
order nicole_windswath2, a(nicole_windswath)

gen nicole_cyclonic=(nicole_windswath>0)
replace nicole_cyclonic=. if nicole_windswath==.
label var nicole_cyclonic "Hurricane Nicole Cyclonic Winds"
order nicole_cyclonic, b(nicole_windswath)

foreach x of var nicole_windswath34 nicole_windswath50 nicole_windswath64 nicole_cyclonic nicole_windswath nicole_windswath2 {
replace `x'=. if focalsample2==0
}

replace nicole_eyepath=. if focalsample2==0
gen nicole_distance_mi=((nicole_distance)*111)*0.621371
order nicole_distance_mi, a(nicole_distance)
label var nicole_distance_mi "Distance to Hurricane Nicole Eyepath"

gen nicole_proximity=1/nicole_distance_mi
order nicole_proximity, b(nicole_distance)
label var nicole_proximity "Hurricane Nicole Proximity to Eyepath"
egen std_nicole_proximity=std(nicole_proximity)
order std_nicole_proximity, b(nicole_proximity)
label var std_nicole_proximity "Hurricane Nicole Proximity to Eyepath"

replace nicole_surge=. if focalsample2==0
gen i_nicole_surge=(nicole_surge>=1)
replace i_nicole_surge=. if nicole_surge==.
order i_nicole_surge, a(nicole_surge)
label var i_nicole_surge  "Hurricane Nicole Storm Surge (=1)"
order nicole_surge i_nicole_surge, a(nicole_windswath2)

sort respondent_id
save "${data}/Survey/survey_final.dta", replace

swindex nicole_surge nicole_windswath nicole_eyepath, gen(nicole_index1)
label var nicole_index1 "Hurricane Nicole Exposure Index"

gen binary_nicoleindex1=(nicole_index1>-.6569326)
replace binary_nicoleindex1=. if nicole_index1==.
label var binary_nicoleindex1 "Hurricane Nicole Exposure Index (=1)"
order binary_nicoleindex1, a(nicole_index1)

compress
sort respondent_id
save "${data}/Survey/survey_final.dta", replace

********************************************************************************
*								ADD ELECTION DATA							   *
********************************************************************************

import delimited "${data}/Covariates/countypres_2000-2020.csv", clear

keep if year==2020
ren county_fips geoid
replace geoid=11001 if state=="DISTRICT OF COLUMBIA"
drop if geoid==.
collapse (sum) candidatevotes (max) totalvotes, by(geoid party)
gen voteshare= candidatevotes/totalvotes
gen demvote20= voteshare if party=="DEMOCRAT"
gen repvote20= voteshare if party=="REPUBLICAN"
collapse (max) demvote20 repvote20, by(geoid)
tempfile vote
save `vote'

use "${data}/Survey/survey_final.dta", clear

merge m:1 geoid using `vote'
drop if _m==2
drop _m
label var demvote20 "2020 Democratic Voteshare"
label var repvote20 "2020 Republican Voteshare"
gen trump20=(repvote20>.50)
replace trump20=. if repvote20==.
order trump20, a(repvote20)
label var trump20 "Trump Won in 2020"

compress
sort respondent_id
save "${data}/Survey/survey_final.dta", replace

********************************************************************************
*								ADD POPULATION DATA							   *
********************************************************************************

import delimited "${data}/Covariates/pop2021.csv", clear

keep stname ctyname popestimate2021 domesticmig2021 internationalmig2021 netmig2021
ren stname state
ren ctyname county
gen dmig2021=domesticmig2021/popestimate2021
gen imig2021=internationalmig2021/popestimate2021
gen nmig2021=netmig2021/popestimate2021
drop if state==county

tempfile mappop
save `mappop'

replace county = subinstr(county, " County", "", .)
replace county = subinstr(county, " Parish", "", .)
replace county = subinstr(county, " Borough", "", .)
replace county = subinstr(county, " Census Area", "", .)
replace county = subinstr(county, " city", " City", .)
replace county="Norfolk" if county=="Norfolk City"
replace county="Chesapeake" if county=="Chesapeake City"

tempfile pop
save `pop'

use "${data}/Survey/survey_final.dta", clear

merge m:1 state county using `pop'
drop if _m==2
drop _m internationalmig2021 domesticmig2021 netmig2021

ren popestimate2021 pop2021
label var pop2021 "2021 Population"
label var dmig2021 "2021 Domestic Migration Rate"
label var imig2021 "2021 International Migration Rate"
label var nmig2021 "2021 Net Migration Rate"
gen pop1000=pop2021/1000
replace ian_waze=(ian_waze/pop1000)
drop pop1000

gen ian_waze50=(ian_waze>=3.024386)
label var ian_waze50 "Hurricane Ian Road Incidents (Top 50 %Tile)"
gen ian_waze75=(ian_waze>=3.80126)
label var ian_waze75 "Hurricane Ian Road Incidents (Top 25 %Tile)"
gen ian_waze90=(ian_waze>=5.740373)
label var ian_waze90 "Hurricane Ian Road Incidents (Top 10 %Tile)"
replace ian_waze50=. if ian_waze==.
replace ian_waze75=. if ian_waze==.
replace ian_waze90=. if ian_waze==.
order ian_waze50 ian_waze75 ian_waze90, a(ian_waze)

compress
sort respondent_id
save "${data}/Survey/survey_final.dta", replace

********************************************************************************
*								MAP DESCRIPTIVES							   *
********************************************************************************

keep if focalsample2==1
keep geoid emg_command personal_hurricane community_hurricane climmig_scale
gen response=1
gen anyclimmig=(climmig_scale>0)

collapse (sum) response (mean) community_hurricane personal_hurricane anyclimmig, by(geoid)

tempfile map
save `map'

import delimited "${data}/Covariates/countypres_2000-2020.csv", clear
keep if year==2020
ren county_fips geoid
keep if state=="TEXAS" | state=="LOUISIANA" | state=="FLORIDA" | state=="NORTH CAROLINA"
collapse (sum) candidatevotes (max) totalvotes, by(geoid party)
gen voteshare= candidatevotes/totalvotes
gen demvote20= voteshare if party=="DEMOCRAT"
gen repvote20= voteshare if party=="REPUBLICAN"
collapse (max) demvote20 repvote20, by(geoid)

merge 1:1 geoid using `map'
drop if _m==2
replace response=0 if _m==1
replace community_hurricane=-99 if _m==1
replace personal_hurricane=-99 if _m==1
replace anyclimmig=-99 if _m==1
drop _m

merge 1:1 geoid using "${data}/Hurricane/ian_geo.dta"
drop if _m==2
gen i_ian_deaths=(ian_deaths>0)
order i_ian_deaths, b(ian_deaths)
label var i_ian_deaths "Hurricane Ian Deaths (=1)"
drop _m

replace ian_windswath34=1 if ian_windswath64==1
replace ian_windswath50=1 if ian_windswath64==1
replace ian_windswath34=1 if ian_windswath50==1
label var ian_windswath34 "Hurricane Ian Tropical Storm-Force Windswath"
label var ian_windswath50 "Hurricane Ian Storm-Force Windswath"
label var ian_windswath64 "Hurricane Ian Hurricane-Force Windswath"
gen ian_windswath=0
replace ian_windswath=1 if ian_windswath34==1
replace ian_windswath=2 if ian_windswath50==1
replace ian_windswath=3 if ian_windswath64==1
label var ian_windswath "Hurricane Ian Maximum Windswath"
label val ian_windswath windswath
order ian_windswath, a(ian_windswath64)

replace ian_distance=((ian_distance)*111)*0.621371
ren ian_distance ian_distance_mi
label var ian_distance_mi "Distance to Hurricane Ian Eyepath"

gen ian_eyepath_broad=ian_eyepath
replace ian_eyepath_broad=1 if geoid==12081 | geoid==12027 | geoid==12055 | geoid==37153 | geoid==12049 | geoid==37167 | geoid==37123 | geoid==12095 | geoid==37125 | geoid==12043 | geoid==12097 | geoid==37037 | geoid==37007 | geoid==12071 | geoid==12115 | geoid==37047 | geoid==12009 | geoid==12105 | geoid==37093 | geoid==37165 | geoid==12093 | geoid==12015 | geoid==12061 | geoid==12127 | geoid==37155 | geoid==37151
label var ian_eyepath_broad "Hurricane Ian Eyepath + 26mi Buffer"
order ian_eyepath_broad, a(ian_eyepath)

swindex ian_surge ian_windswath ian_eyepath, gen(hurricane_index1)
replace hurricane_index1=. if ian_surge==.
label var hurricane_index1 "Hurricane Exposure Index"
swindex ian_surge ian_windswath ian_eyepath ian_evacuation ian_deaths, gen(hurricane_index2)
replace hurricane_index2=. if ian_surge==.
label var hurricane_index2 "Hurricane Exposure Index"

merge 1:1 geoid using `waze'
drop if _m==2
label var ian_waze "Hurricane Ian Road Incidents"
gen i_ian_waze=(ian_waze>0)
order i_ian_waze, b(ian_waze)
label var i_ian_waze "Hurricane Ian Road Incident (=1)"
replace i_ian_waze=0 if _m==1
replace ian_waze=0 if _m==1
replace i_ian_waze=. if state=="North Carolina"
replace ian_waze=. if state=="North Carolina"
order i_ian_waze ian_waze, a(ian_evacuation)
drop _m

merge m:1 state county using `mappop'
drop if _m==2
drop _m internationalmig2021 domesticmig2021 netmig2021 dmig2021 imig2021 nmig2021
ren popestimate2021 pop2021
gen pop1000=pop2021/1000
replace ian_waze=(ian_waze/pop1000)
drop pop1000 pop2021

tempfile final
save `final'

use "${data}/Hurricane/ian_geo.dta", clear
keep geoid emg_command

tempfile emg
save `emg'

use `final', clear
merge 1:1 geoid using `emg'
drop if _m==2
order emg_command, a(geoid)
drop _m

order geoid county state emg_command response community_hurricane personal_hurricane anyclimmig hurricane_index1 hurricane_index2 ian_distance ian_eyepath ian_eyepath_broad ian_windswath34 ian_windswath50 ian_windswath64 ian_windswath i_ian_deaths ian_deaths ian_evacuation ian_surge fema_aid i_ian_waze ian_waze demvote20 repvote20
label var geoid "County ID"
label var response "# of Survey Respondents"
label var community_hurricane "% Community Exposure to Hurricanes"
label var personal_hurricane "% Personal Exposure to Hurricanes"
label var anyclimmig "% Familiar w/ a Climate Migrant"
label var demvote20 "2020 Democratic Voteshare"
label var repvote20 "2020 Republican Voteshare"

gen i_index=(hurricane_index1>-.35)
label var i_index "Hurricane Ian Exposure"

gen hurricane_pctile=0
replace hurricane_pctile=1 if hurricane_index1>=-.2508482 & hurricane_index1<=0
replace hurricane_pctile=2 if hurricane_index1>0 & hurricane_index1<=.7645571
replace hurricane_pctile=3 if hurricane_index1>.7645571 & hurricane_index1<=1.779962
replace hurricane_pctile=4 if hurricane_index1>1.779962 & hurricane_index1<=3.902821
replace hurricane_pctile=5 if hurricane_index1>3.902821
label var hurricane_pctile "Hurricane Ian Exposure Bins"

compress
save "${data}/Survey/map_descriptives.dta", replace

use "${data}/Survey/map_descriptives.dta", clear

merge 1:1 geoid using "${data}/Hurricane/ida_geo.dta"
drop if _m==2
drop _m

replace ida_windswath34=1 if ida_windswath64==1
replace ida_windswath50=1 if ida_windswath64==1
replace ida_windswath34=1 if ida_windswath50==1
label var ida_windswath34 "Hurricane Ida Tropical Storm-Force Windswath"
label var ida_windswath50 "Hurricane Ida Storm-Force Windswath"
label var ida_windswath64 "Hurricane Ida Hurricane-Force Windswath"
gen ida_windswath=0
replace ida_windswath=1 if ida_windswath34==1
replace ida_windswath=2 if ida_windswath50==1
replace ida_windswath=3 if ida_windswath64==1
label var ida_windswath "Hurricane Ida Maximum Windswath"
label val ida_windswath windswath
order ida_windswath, a(ida_windswath64)

replace ida_distance=((ida_distance)*111)*0.621371
ren ida_distance ida_distance_mi
label var ida_distance_mi "Distance to Hurricane Ida Eyepath"

swindex ida_surge ida_windswath ida_eyepath, gen(ida_index1)
replace ida_index1=. if ian_surge==.
label var ida_index1 "Hurricane Ida Exposure Index"

gen ida_pctile=0
replace ida_pctile=1 if ida_index1>=-.197748 & ida_index1<=0
replace ida_pctile=2 if ida_index1>0 & ida_index1<=1.092683
replace ida_pctile=3 if ida_index1>1.092683 & ida_index1<=2.286799
replace ida_pctile=4 if ida_index1>2.286799 & ida_index1<=2.640905
replace ida_pctile=5 if ida_index1>2.640905
label var ida_pctile "Hurricane Ida Exposure Bins"

compress
save "${data}/Survey/map_descriptives.dta", replace

use "${data}/Survey/map_descriptives.dta", clear

merge 1:1 geoid using "${data}/Hurricane/nicole_geo.dta"
drop if _m==2
drop _m

replace nicole_windswath34=1 if nicole_windswath64==1
replace nicole_windswath50=1 if nicole_windswath64==1
replace nicole_windswath34=1 if nicole_windswath50==1
label var nicole_windswath34 "Hurricane Nicole Tropical Storm-Force Windswath"
label var nicole_windswath50 "Hurricane Nicole Storm-Force Windswath"
label var nicole_windswath64 "Hurricane Nicole Hurricane-Force Windswath"
gen nicole_windswath=0
replace nicole_windswath=1 if nicole_windswath34==1
replace nicole_windswath=2 if nicole_windswath50==1
replace nicole_windswath=3 if nicole_windswath64==1
label var nicole_windswath "Hurricane Nicole Maximum Windswath"
label val nicole_windswath windswath
order nicole_windswath, a(nicole_windswath64)

replace nicole_distance=((nicole_distance)*111)*0.621371
ren nicole_distance nicole_distance_mi
label var nicole_distance_mi "Distance to Hurricane Nicole Eyepath"

swindex nicole_surge nicole_windswath nicole_eyepath, gen(nicole_index1)
replace nicole_index1=. if nicole_surge==.
label var nicole_index1 "Hurricane Nicole Exposure Index"

gen nicole_pctile=0
replace nicole_pctile=1 if nicole_index1>0 & nicole_index1<=.7911545
replace nicole_pctile=2 if nicole_index1>.7911545 & nicole_index1<=1.396833
replace nicole_pctile=3 if nicole_index1>1.396833 & nicole_index1<=2.002511
replace nicole_pctile=4 if nicole_index1>2.002511  & nicole_index1<=4.55408
replace nicole_pctile=5 if nicole_index1>4.55408
label var nicole_pctile "Hurricane Nicole Exposure Bins"

compress
save "${data}/Survey/map_descriptives.dta", replace

********************************************************************************

********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************
********************************************************************************

import delimited "${data}/Survey/followup_completes_geocoded.csv", clear
est drop _all

********************************************************************************
*								CLEAN SURVEY DATA							   *
********************************************************************************

gen start_date = dofc(clock(startdate, "MD20Yhm"))
format start_date %td

gen end_date = dofc(clock(enddate, "MD20Yhm"))
format end_date %td

drop startdate enddate progress recordeddate finished recipientlastname recipientfirstname recipientemail externalreference countyns affgeoid namelsad stusps rid age_1 gender_1 hhi ethnicity hispanic education_1 political_party region zip clicked userlanguage rel_import_time_firstclick rel_import_time_lastclick rel_import_time_pagesubmit rel_import_time_clickcount

order start_date end_date
label var start_date "Interview Start Date"
label var end_date "Interview End Date"

gen obsdrop=0
label var obsdrop "Observation to Drop"
replace obsdrop=1 if start_date!=end_date
replace obsdrop=1 if status=="Survey Preview"
replace obsdrop=1 if distributionchannel=="preview"
drop status distributionchannel

gen wkyr=wofd(start_date)
format wkyr %tw

gen wave=11
drop wkyr
label var wave "Survey Wave"
order wave, first

ren durationinseconds duration
label var duration "Interview Duration (Seconds)"
gen fastest10=(duration<=241)
label var fastest10 "Fast Interview (Duration in Bottom Decile)"
gen slowest10=(duration>=1061)
label var slowest10 "Slow Interview (Duration in Top Decile)"
replace obsdrop=1 if fastest10==1 | slowest10==1

gen respondent_id=_n
label var respondent_id "Respondent ID"
order respondent_id responseid, first
ren responseid lucid_id
label var lucid_id "Lucid ID"

ren locationlatitude latitude
label var latitude "Latitude"
ren locationlongitude longitude
label var longitude "Longitude"
order geoid state_name statefp name countyfp, a(longitude)
label var geoid "County ID"
replace obsdrop=1 if geoid==.
ren state_name state
label var state "State"
label var statefp "State FIPS"
ren name county
label var county "County"
label var countyfp "County FIPS"

gen woman=(gender=="Female")
replace gender="0" if gender=="Neither/Prefer not to say"
replace gender="1" if gender=="Male"
replace gender="2" if gender=="Female"
destring gender, replace
label define gender 0 "Neither/Prefer Not to Say" 1 "Male" 2 "Female"
label val gender gender
order woman, a(gender)
label var woman "Woman Respondent"
label var gender "Gender"

replace education="0" if education=="Elementary or some high school"
replace education="1" if education=="High school graduate/GED"
replace education="2" if education=="Some college/AssociateÃ¢â¬â¢s degree"
replace education="2" if education=="Some college/Associateâs degree"
replace education="3" if education=="Trade or vocational certification"
replace education="4" if education=="College graduate"
replace education="5" if education=="Post-graduate degree"
destring education, replace
label define education 0 "Some High School or Less" 1 "High School" 2 "Some College" 3 "Trade Certification" 4 "College Degree" 5 "Graduate Degree"
label val education education
label var education "Education"
gen college=(education>=4)
label var college "College Graduate"
gen highschool=(inrange(education, 1,3))
label var highschool "High School Graduate"
order highschool college, a(education)

replace ideology="0" if ideology=="Extremely conservative"
replace ideology="1" if ideology=="Conservative"
replace ideology="2" if ideology=="Slightly conservative"
replace ideology="3" if ideology=="Moderate, middle of the road"
replace ideology="4" if ideology=="Slightly liberal"
replace ideology="5" if ideology=="Liberal"
replace ideology="6" if ideology=="Extremely liberal"
destring ideology, replace
label define ideology 0 "Very Conservative" 1 "Conservative" 2 "Somewhat Conservative" 3 "Moderate" 4 "Somewhat Liberal" 5 "Liberal" 6 "Very Liberal"
label val ideology ideology
label var ideology "Ideology"
gen conservative=(ideology<=2)
label var conservative "Conservative"
gen liberal=(ideology>=4)
label var liberal "Liberal"
order conservative liberal, a(ideology)
replace partisanship="0" if partisanship=="Republican"
replace partisanship="1" if partisanship=="Independent"
replace partisanship="2" if partisanship=="Democrat"
destring partisanship, replace
ren partisanship party
label define party 0 "Republican" 1 "Independent" 2 "Democrat"
label val party party
label var party "Party ID"
gen republican=(party==0)
label var republican "Republican"
gen democrat=(party==2)
label var democrat "Democrat"
order republican democrat, a(party)
gen partisanship=.
replace partisanship=0 if partisanship_r=="Strong Republican"
replace partisanship=1 if partisanship_r=="Not very strong Republican"
replace partisanship=2 if partisanship_i=="Closer to the Republican Party"
replace partisanship=3 if partisanship_i=="Closer to the Democratic Party"
replace partisanship=4 if partisanship_d=="Not very strong Democrat"
replace partisanship=5 if partisanship_d=="Strong Democrat"
label define partisanship 0 "Strong Republican" 1 "Republican" 2 "Lean Republican" 3 "Lean Democrat" 4 "Democrat" 5 "Strong Democrat"
label val partisanship partisanship
label var partisanship "Partisanship"
order partisanship, a(party)
drop partisanship_d partisanship_r partisanship_i

gen botfilter1=(bot_filter_3=="Red" & bot_filter_5=="Green")
label var botfilter1 "Passed Bot Filter"
gen botfilter2=(bot_filter_3=="Red" | bot_filter_5=="Green")
label var botfilter2 "Passed One Leg of Bot Filter"
order botfilter1 botfilter2, b(obsdrop)
replace obsdrop=1 if botfilter1==0
drop bot_filter_1 bot_filter_2 bot_filter_3 bot_filter_4 bot_filter_5 bot_filter_6

replace religiosity="0" if religiosity=="Never"
replace religiosity="1" if religiosity=="Once a year or less"
replace religiosity="2" if religiosity=="A few times a year"
replace religiosity="3" if religiosity=="A few times a month"
replace religiosity="4" if religiosity=="Once a week"
replace religiosity="5" if religiosity=="More than once a week"
destring religiosity, replace
label define religiosity 0 "Attend Worship: Never" 1 "Attend Worship: Once a Year" 2 "Attend Worship: Few Times a Year" 3 "Attend Worship: Few Times a Month" 4 "Attend Worship: Once a Week" 5 "Attend Worship: Few Times a Week"
label val religiosity religiosity
label var religiosity "Religiosity"

replace native_born="0" if native_born=="Prefer not to say"
replace native_born="1" if native_born=="Somewhere Else"
replace native_born="2" if native_born=="United States"
destring native_born, replace
label define native_born 0 "Prefer Not to Say" 1 "Born Outside US" 2 "Born in US"
label val native_born native_born
label var native_born "Nativity"
gen native=(native_born==2)
label var native "Born in US"
order native, a(native_born)

replace employment="0" if employment=="Unemployed "
replace employment="1" if employment=="Retired"
replace employment="2" if employment=="Homemaker"
replace employment="3" if employment=="Student"
replace employment="4" if employment=="Self-employed"
replace employment="5" if employment=="Employed part time "
replace employment="5" if employment=="Employed full time"
destring employment, replace
label define employment 0 "Unemployed" 1 "Retired" 2 "Homemaker" 3 "Student" 4 "Self-Employed" 5 "Employed Part-Time" 6 "Employed Full-Time"
label val employment employment
label var employment "Employment Status"
gen employed=(employment>=4)
order employed, a(employment)
label var employed "Employed"

replace age="65" if age=="Sixty five"
replace age="24" if age=="L24"
replace age="58" if age==",58"
replace age="22" if age=="222"
replace age="39" if age=="3("
replace age="33" if age=="3e"
replace age="49" if age=="4("
replace age="51" if age=="5q"
destring age, replace
label var age "Age"
replace obsdrop=1 if age<18

replace trust_govt="0" if trust_govt=="Only some of the time"
replace trust_govt="1" if trust_govt=="Most of the time"
replace trust_govt="2" if trust_govt=="Just about always"
destring trust_govt, replace
label define trust_govt 0 "Sometimes" 1 "Most of the Time" 2 "Always"
label val trust_govt trust_govt
label var trust_govt "Trust Government"

replace pol_interest="0" if pol_interest=="Hardly at all"
replace pol_interest="1" if pol_interest=="Only now and then"
replace pol_interest="2" if pol_interest=="Some of the time"
replace pol_interest="3" if pol_interest=="Most of the time"
destring pol_interest, replace
label define pol_interest 0 "Hardly at All" 1 "Now and Then" 2 "Some of the Time" 3 "Most of the Time"
label val pol_interest pol_interest
label var pol_interest "Political Interest"

replace latino="0" if latino=="No"
replace latino="0" if latino=="Perfer not to say"
replace latino="1" if latino=="Yes"
destring latino, replace
ren latino race_latinx
label var race_latinx "Race: Latinx"
gen race_white=(race_1=="White or Caucasian")
label var race_white "Race: White/Caucasian"
gen race_black=(race_2=="Black or African American")
label var race_black "Race: Black/African American"
gen race_indigenous=(race_3=="American Indian/Native American or Alaska Native" | race_5=="Native Hawaiian or Other Pacific Islander")
label var race_indigenous "Race: American Indian/Native American/Alaska Native/Native Hawaiian/Pacific Islander"
gen race_asian=(race_4=="Asian")
label var race_asian "Race: Asian"
gen race_other=(race_6=="Other" | race_7=="Prefer not to say")
label var race_other "Race: Other"
egen race_sum=rowtotal(race_white race_black race_latinx race_asian race_indigenous race_other)
gen race_multi=race_sum>1
replace race_multi=0 if race_white==1 & race_latinx==1
label var race_multi "Race: Multiracial"
order race_white race_black race_multi race_latinx race_asian race_indigenous race_other, a(pol_interest)
drop race_1 race_2 race_3 race_4 race_5 race_6 race_7 race_sum
gen race=.
replace race=0 if race_multi==0 & race_white==1
replace race=1 if race_multi==0 & race_black==1
replace race=2 if race_multi==0 & race_latinx==1
replace race=3 if race_multi==0 & race_asian==1
replace race=4 if race_multi==0 & race_indigenous==1
replace race=5 if race_multi==0 & race_other==1
replace race=6 if race_multi==1
label define race 0 "White" 1 "Black" 2 "Latinx" 3 "Asian" 4 "Indigenous" 5 "Other" 6 "Multiracial"
label val race race
label var race "Race"
order race, a(pol_interest)

replace income="0" if income=="Prefer not to say"
replace income="1" if income=="Less than $25,000"
replace income="2" if income=="$25,000-$49,999"
replace income="3" if income=="$50,000-$74,999"
replace income="4" if income=="$75,000-$99,999"
replace income="5" if income=="$100,000-$149,999"
replace income="6" if income=="$150,000 or more"
destring income, replace
label define income 0 "Prefer Not to Say" 1 "< $25,000" 2 "$25,000-$49,999" 3 "$50,000-$74,999" 4 "$75,000-$99,999" 5 "$100,000-$149,999" 6 "$150,000+"
label val income income
label var income "Income"

replace empathy_1="0" if empathy_1=="Does not describe me at all"
replace empathy_1="1" if empathy_1=="Describes me very little"
replace empathy_1="2" if empathy_1=="Describes me moderately well"
replace empathy_1="3" if empathy_1=="Describes me fairly well"
replace empathy_1="4" if empathy_1=="Describes me very well"
destring empathy_1, replace
label define empathy_1 0 "Doesn't Describe Me" 1 "Describes Me Little" 2 "Describes Me Somewhat" 3 "Describes Me Fairly Well" 4 "Describes Me Well"
label val empathy_1 empathy_1
ren empathy_1 empathy1
label var empathy1 "Feel protective when I see others being taken advantage."
replace empathy_2="4" if empathy_2=="Does not describe me at all"
replace empathy_2="3" if empathy_2=="Describes me very little"
replace empathy_2="2" if empathy_2=="Describes me moderately well"
replace empathy_2="1" if empathy_2=="Describes me fairly well"
replace empathy_2="0" if empathy_2=="Describes me very well"
destring empathy_2, replace
label define empathy_2 0 "Describes Me Well" 1 "Describes Me Fairly Well" 2 "Describes Me Somewhat" 3 "Describes Me Little" 4 "Doesn't Describe Me"
label val empathy_2 empathy_2
ren empathy_2 empathy2
label var empathy2 "Other's misfortunes do not bother me."
replace empathy_3="4" if empathy_3=="Does not describe me at all"
replace empathy_3="3" if empathy_3=="Describes me very little"
replace empathy_3="2" if empathy_3=="Describes me moderately well"
replace empathy_3="1" if empathy_3=="Describes me fairly well"
replace empathy_3="0" if empathy_3=="Describes me very well"
destring empathy_3, replace
label define empathy_3 0 "Describes Me Well" 1 "Describes Me Fairly Well" 2 "Describes Me Somewhat" 3 "Describes Me Little" 4 "Doesn't Describe Me"
label val empathy_3 empathy_3
ren empathy_3 empathy3
label var empathy3 "If I'm sure I'm right, I don't listen to other's opinions."
replace empathy_4="0" if empathy_4=="Does not describe me at all"
replace empathy_4="1" if empathy_4=="Describes me very little"
replace empathy_4="2" if empathy_4=="Describes me moderately well"
replace empathy_4="3" if empathy_4=="Describes me fairly well"
replace empathy_4="4" if empathy_4=="Describes me very well"
destring empathy_4, replace
label define empathy_4 0 "Doesn't Describe Me" 1 "Describes Me Little" 2 "Describes Me Somewhat" 3 "Describes Me Fairly Well" 4 "Describes Me Well"
label val empathy_4 empathy_4
ren empathy_4 empathy4
label var empathy4 "I try to see both sides to every story."
swindex empathy1 empathy2 empathy3 empathy4, gen(empathy)
order empathy, b(empathy1)
label var empathy "Empathy Index"
drop empathy1 empathy2 empathy3 empathy4

gen community_flood=(experience_cc_com_1=="Floods")
label var community_flood "Community Experienced Flood in Past Year"
gen community_hurricane=(experience_cc_com_2=="Hurricanes")
label var community_hurricane "Community Experienced Hurricane in Past Year"
gen community_fire=(experience_cc_com_3=="Wildfires")
label var community_fire "Community Experienced Wildfire in Past Year"
gen community_drought=(experience_cc_com_4=="Droughts")
label var community_drought "Community Experienced Drought in Past Year"
gen community_heat=(experience_cc_com_5=="Heatwaves")
label var community_heat "Community Experienced Heatwave in Past Year"
gen community_cc=(community_flood==1 | community_hurricane==1 | community_fire==1 | community_drought==1 | community_heat==1)
label var community_cc "Community Experienced Extreme Weather in Past Year"
order community_cc community_hurricane community_flood community_fire community_drought community_heat, a(empathy)
drop experience_cc_com_1 experience_cc_com_2 experience_cc_com_3 experience_cc_com_4 experience_cc_com_5 experience_cc_com_6

gen personal_flood=(experience_cc_per_1=="Floods")
label var personal_flood "Personally Experienced Flood in Past Year"
gen personal_hurricane=(experience_cc_per_2=="Hurricanes")
label var personal_hurricane "Personally Experienced Hurricane in Past Year"
gen personal_fire=(experience_cc_per_3=="Wildfires")
label var personal_fire "Personally Experienced Wildfire in Past Year"
gen personal_drought=(experience_cc_per_4=="Droughts")
label var personal_drought "Personally Experienced Drought in Past Year"
gen personal_heat=(experience_cc_per_5=="Heatwaves")
label var personal_heat "Personally Experienced Heatwave in Past Year"
gen personal_cc=(personal_flood==1 | personal_hurricane==1 | personal_fire==1 | personal_drought==1 | personal_heat==1)
label var personal_cc "Personally Experienced Extreme Weather in Past Year"
order personal_cc personal_hurricane personal_flood personal_fire personal_drought personal_heat, a(community_heat)
drop experience_cc_per_1 experience_cc_per_2 experience_cc_per_3 experience_cc_per_4 experience_cc_per_5 experience_cc_per_6

gen climmig_personal=(experience_cm_1=="I personally have moved because of climate-related reasons")
label var climmig_personal "Personal Climate Migration"
gen climmig_family=(experience_cm_2=="Someone in my family has moved because of climate-related reasons")
label var climmig_family "Family Climate Migration"
gen climmig_friend=(experience_cm_3=="A close friend has moved because of climate-related reasons")
label var climmig_friend "Friend Climate Migration"
gen climmig_acquaintance=(experience_cm_4=="An acquaintance has moved because of climate-related reasons")
label var climmig_acquaintance "Acquaintance Climate Migration"
gen climmig_know=(climmig_personal==1 | climmig_family==1 | climmig_friend==1 | climmig_acquaintance==1)
label var climmig_know "Know a Climate Migrant"
order climmig_know climmig_personal climmig_family climmig_friend climmig_acquaintance, a(personal_heat)
drop experience_cm_1 experience_cm_2 experience_cm_3 experience_cm_4 experience_cm_5

gen climmig_reason_flood=(cm_reason_1=="Floods")
label var climmig_reason_flood "Reason for Climate Migration: Floods"
gen climmig_reason_hurricane=(cm_reason_2=="Hurricanes")
label var climmig_reason_hurricane "Reason for Climate Migration: Hurricanes"
gen climmig_reason_fire=(cm_reason_4=="Wildfires")
label var climmig_reason_fire "Reason for Climate Migration: Wildfire"
gen climmig_reason_drought=(cm_reason_3=="Droughts" | cm_reason_5=="Droughts")
label var climmig_reason_drought "Reason for Climate Migration: Drought"
gen climmig_reason_heat=(cm_reason_6=="Heatwaves" | cm_reason_7_text=="Extreme heat and cold and an energy grid that is unstable" | cm_reason_7_text=="humid temperature" | cm_reason_7_text=="Because was too hot in the summer ")
label var climmig_reason_heat "Reason for Climate Migration: Heatwave"
gen climmig_reason_winter=(cm_reason_7_text=="winter weather" | cm_reason_7_text=="snow caved in my roof which cause a fire" | cm_reason_7_text=="snow" | cm_reason_7_text=="hard winters" | cm_reason_7_text=="cold" | cm_reason_7_text=="Too much snow " | cm_reason_7_text=="Too cold" | cm_reason_7_text=="Snow storms" | cm_reason_7_text=="Snow " | cm_reason_7_text=="Snow" | cm_reason_7_text=="Ice" | cm_reason_7_text=="Frozen weather" | cm_reason_7_text=="Freeze" | cm_reason_7_text=="Extreme Winter Cold" | cm_reason_7_text=="Cold winters" | cm_reason_7_text=="Cold winter weather" | cm_reason_7_text=="Cold weather " | cm_reason_7_text=="Cold weather" | cm_reason_7_text=="Cold and ice" | cm_reason_7_text=="Cold Snowy Winter" | cm_reason_7_text=="Blizzards " | cm_reason_7_text=="Extreme heat and cold and an energy grid that is unstable")
label var climmig_reason_winter "Reason for Climate Migration: Winter Weather"
gen climmig_reason_tornado=(cm_reason_7_text=="tornadoes" | cm_reason_7_text=="Tornadoes " | cm_reason_7_text=="Tornado's" | cm_reason_7_text=="Tornado destroyed their home " | cm_reason_7_text=="Tornado " | cm_reason_7_text=="Tornado" | cm_reason_7_text=="Lightning strike")
label var climmig_reason_tornado "Reason for Climate Migration: Tornadoes"
gen climmig_reason_other=(cm_reason_7_text!="" & climmig_reason_winter==0 & climmig_reason_tornado==0 & climmig_reason_heat==0)
label var climmig_reason_other "Reason for Climate Migration: Other"
drop cm_reason_1 cm_reason_2 cm_reason_3 cm_reason_4 cm_reason_5 cm_reason_6 cm_reason_7 cm_reason_7_text
order climmig_reason_hurricane climmig_reason_flood climmig_reason_fire climmig_reason_drought climmig_reason_heat climmig_reason_winter climmig_reason_tornado climmig_reason_other, a(climmig_acquaintance)

replace cm_scale="0" if cm_scale==""
replace cm_scale="1" if cm_scale=="Few people"
replace cm_scale="2" if cm_scale=="Some people"
replace cm_scale="3" if cm_scale=="Many people"
destring cm_scale, replace
label define cm_scale 0 "None" 1 "Few People" 2 "Some People" 3 "Many People"
label val cm_scale cm_scale
label var cm_scale "Scale of Climate Migration Experienced"
ren cm_scale climmig_scale
order climmig_scale, a(climmig_acquaintance)

replace rent_own="0" if rent_own=="Neither"
replace rent_own="1" if rent_own=="Rent"
replace rent_own="2" if rent_own=="Own"
destring rent_own, replace
label define rent_own 0 "Neither" 1 "Rent" 2 "Own"
label val rent_own rent_own
label var rent_own "Rent/Own Residence"
ren rent_own rentown
order rentown, a(income)
gen owner=(rentown==2)
label var owner "Home Owner"
order owner, a(rentown)

replace time_in_comm="0" if time_in_comm=="Less than 1 year"
replace time_in_comm="1" if time_in_comm=="1-3 years"
replace time_in_comm="2" if time_in_comm=="3-6 years"
replace time_in_comm="3" if time_in_comm=="7-10 years"
replace time_in_comm="4" if time_in_comm=="10 or more years"
destring time_in_comm, replace
label define time_in_comm 0 "< 1 Year" 1 "1-3 Years" 2 "4-6 Years" 3 "7-10 Years" 4 "10+ Years"
label val time_in_comm time_in_comm
label var time_in_comm "Time Living in Community"
ren time_in_comm timecomm
order timecomm, a(owner)

replace community_links="0" if community_links=="No, I am not a member of a a club, group, or association"
replace community_links="1" if community_links=="Yes, I am a member of one club, group, or association"
replace community_links="2" if community_links=="Yes, I am a member of more than one club, group, or association"
destring community_links, replace
label define community_links 0 "0 Groups" 1 "1 Group" 2 "2+ Groups"
label val community_links community_links
label var community_links "Membership in Community Groups"
order community_links, a(timecomm)
gen commgroup=(community_links>=1)
label var commgroup "Community Group"
order commgroup, a(community_links)

replace move_intent="0" if move_intent=="I have no plans to move someplace new"
replace move_intent="1" if move_intent=="I am planning on moving someplace new within the next year"
replace move_intent="2" if move_intent=="I am planning on moving someplace new within the next 1-3 years"
replace move_intent="3" if move_intent=="I am planning on moving someplace new within the next 3-6 years"
destring move_intent, replace
label define move_intent 0 "No Plans to Move" 1 "Move in Next Year" 2 "Move in 1-3 Years" 3 "Move in 3-6 Years"
label val move_intent move_intent
label var move_intent "Intentions to Move"
gen willmove=(move_intent>=1)
label var willmove "Intend to Move"
order willmove, a(move_intent)
replace move_coastal="0" if move_coastal=="Much closer to the coast"
replace move_coastal="1" if move_coastal=="Somewhat closer to the coast"
replace move_coastal="2" if move_coastal=="Neither closer to nor further from the coast"
replace move_coastal="3" if move_coastal=="Somewhat further away from the coast"
replace move_coastal="4" if move_coastal=="Much further away from the coast"
destring move_coastal, replace
label define move_coastal 0 "Much Closer to Coast" 1 "Somewhat Closer to Coast" 2 "Same Distance from Coast" 3 "Somewhat Further from Coast" 4 "Much Further from Coast"
label val move_coastal move_coastal
label var move_coastal "Direction of Move if Intentending to Move"
gen willmovefurther=(inrange(move_coastal,3,4))
label var willmovefurther "Intend to Move"
order willmovefurther, a(move_coastal)

replace cc_move="0" if cc_move=="No, makes me much less likely to move"
replace cc_move="1" if cc_move=="No, makes me somewhat less likely to move"
replace cc_move="2" if cc_move=="Does not affect my likelihood of moving"
replace cc_move="3" if cc_move=="Yes, makes me somwhat more likely to move"
replace cc_move="4" if cc_move=="Yes, makes me much more likely to move"
destring cc_move, replace
label define cc_move 0 "Less Likely to Move" 1 "Somewhat Less Likely to Move" 2 "Doesn't Affect Move Likelihood" 3 "Somewhat More Likely to Move" 4 "More Likely to Move"
label val cc_move cc_move
label var cc_move "Climate Change Impact on Intentions to Move"
gen willmoveclimate=(cc_move>=3)
label var willmoveclimate "Intend to Move Because of Climate Change"
order willmoveclimate, a(cc_move)
label var cc_move_open "Climate Change Impact on Intentions to Move (Text Response)"

replace climate_mig_1="0" if climate_mig_1=="Definitely agree"
replace climate_mig_1="1" if climate_mig_1=="Somewhat agree"
replace climate_mig_1="2" if climate_mig_1=="Neither agree nor disagree"
replace climate_mig_1="3" if climate_mig_1=="Somewhat disagree"
replace climate_mig_1="4" if climate_mig_1=="Definitely disagree"
destring climate_mig_1, replace
label define climate_mig_1 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val climate_mig_1 climate_mig_1
ren climate_mig_1 climatemig1
label var climatemig1 "Climate-driven migration is not a serious problem."
replace climate_mig_2="0" if climate_mig_2=="Definitely disagree"
replace climate_mig_2="1" if climate_mig_2=="Somewhat disagree"
replace climate_mig_2="2" if climate_mig_2=="Neither agree nor disagree"
replace climate_mig_2="3" if climate_mig_2=="Somewhat agree"
replace climate_mig_2="4" if climate_mig_2=="Definitely agree"
destring climate_mig_2, replace
label define climate_mig_2 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_mig_2 climate_mig_2
ren climate_mig_2 climatemig2
label var climatemig2 "Climate-driven migration will have a serious impact during my lifetime."
replace climate_mig_3="0" if climate_mig_3=="Definitely disagree"
replace climate_mig_3="1" if climate_mig_3=="Somewhat disagree"
replace climate_mig_3="2" if climate_mig_3=="Neither agree nor disagree"
replace climate_mig_3="3" if climate_mig_3=="Somewhat agree"
replace climate_mig_3="4" if climate_mig_3=="Definitely agree"
destring climate_mig_3, replace
label define climate_mig_3 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_mig_3 climate_mig_3
ren climate_mig_3 climatemig3
label var climatemig3 "I would vote for a politician who promised to take action to address climate-driven migration."
replace climate_mig_4="0" if climate_mig_4=="Definitely agree"
replace climate_mig_4="1" if climate_mig_4=="Somewhat agree"
replace climate_mig_4="2" if climate_mig_4=="Neither agree nor disagree"
replace climate_mig_4="3" if climate_mig_4=="Somewhat disagree"
replace climate_mig_4="4" if climate_mig_4=="Definitely disagree"
destring climate_mig_4, replace
label define climate_mig_4 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val climate_mig_4 climate_mig_4
ren climate_mig_4 climatemig4
label var climatemig4 "The U.S. should not do more to help climate-driven migrants."
replace climate_mig_5="0" if climate_mig_5=="Definitely disagree"
replace climate_mig_5="1" if climate_mig_5=="Somewhat disagree"
replace climate_mig_5="2" if climate_mig_5=="Neither agree nor disagree"
replace climate_mig_5="3" if climate_mig_5=="Somewhat agree"
replace climate_mig_5="4" if climate_mig_5=="Definitely agree"
destring climate_mig_5, replace
label define climate_mig_5 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_mig_5 climate_mig_5
ren climate_mig_5 climatemig5
label var climatemig5 "The international community should do more to help climate-driven migrants."
foreach x of var climatemig1 climatemig2 climatemig3 climatemig4 climatemig5 {
gen `x'_high=(`x'>=3)
order `x'_high, b(`x')
}
label var climatemig1_high "Climate-driven migration is not a serious problem."
label var climatemig2_high "Climate-driven migration will have a serious impact during my lifetime."
label var climatemig3_high "I would vote for a politician who promised to take action to address climate-driven migration."
label var climatemig4_high "The U.S. should not do more to help climate-driven migrants."
label var climatemig5_high "The international community should do more to help climate-driven migrants."

replace general_mig_1="0" if general_mig_1=="Definitely agree"
replace general_mig_1="1" if general_mig_1=="Somewhat agree"
replace general_mig_1="2" if general_mig_1=="Neither agree nor disagree"
replace general_mig_1="3" if general_mig_1=="Somewhat disagree"
replace general_mig_1="4" if general_mig_1=="Definitely disagree"
destring general_mig_1, replace
label define general_mig_1 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val general_mig_1 general_mig_1
ren general_mig_1 migration1
label var migration1 "Migration is not a serious problem."
replace general_mig_2="0" if general_mig_2=="Definitely disagree"
replace general_mig_2="1" if general_mig_2=="Somewhat disagree"
replace general_mig_2="2" if general_mig_2=="Neither agree nor disagree"
replace general_mig_2="3" if general_mig_2=="Somewhat agree"
replace general_mig_2="4" if general_mig_2=="Definitely agree"
destring general_mig_2, replace
label define general_mig_2 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val general_mig_2 general_mig_2
ren general_mig_2 migration2
label var migration2 "Migration will have a serious impact during my lifetime."
replace general_mig_3="0" if general_mig_3=="Definitely disagree"
replace general_mig_3="1" if general_mig_3=="Somewhat disagree"
replace general_mig_3="2" if general_mig_3=="Neither agree nor disagree"
replace general_mig_3="3" if general_mig_3=="Somewhat agree"
replace general_mig_3="4" if general_mig_3=="Definitely agree"
destring general_mig_3, replace
label define general_mig_3 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val general_mig_3 general_mig_3
ren general_mig_3 migration3
label var migration3 "I would vote for a politician who promised to take action to address migration."
replace general_mig_4="0" if general_mig_4=="Definitely agree"
replace general_mig_4="1" if general_mig_4=="Somewhat agree"
replace general_mig_4="2" if general_mig_4=="Neither agree nor disagree"
replace general_mig_4="3" if general_mig_4=="Somewhat disagree"
replace general_mig_4="4" if general_mig_4=="Definitely disagree"
destring general_mig_4, replace
label define general_mig_4 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val general_mig_4 migration4
ren general_mig_4 migration4
label var migration4 "The U.S. should not do more to help migrants."
replace general_mig_5="0" if general_mig_5=="Definitely disagree"
replace general_mig_5="1" if general_mig_5=="Somewhat disagree"
replace general_mig_5="2" if general_mig_5=="Neither agree nor disagree"
replace general_mig_5="3" if general_mig_5=="Somewhat agree"
replace general_mig_5="4" if general_mig_5=="Definitely agree"
destring general_mig_5, replace
label define general_mig_5 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val general_mig_5 general_mig_5
ren general_mig_5 migration5
label var migration5 "The international community should do more to help climate-driven migrants."
foreach x of var migration1 migration2 migration3 migration4 migration5 {
gen `x'_high=(`x'>=3)
order `x'_high, b(`x')
}
label var migration1_high "Migration is not a serious problem."
label var migration2_high "Migration will have a serious impact during my lifetime."
label var migration3_high "I would vote for a politician who promised to take action to address migration."
label var migration4_high "The U.S. should not do more to help migrants."
label var migration5_high "The international community should do more to help migrants."

replace climate_1="0" if climate_1=="Definitely Agree"
replace climate_1="1" if climate_1=="Somewhat Agree"
replace climate_1="2" if climate_1=="Neither Agree Nor Disagree"
replace climate_1="3" if climate_1=="Somewhat Disagree"
replace climate_1="4" if climate_1=="Definitely Disagree"
destring climate_1, replace
label define climate_1 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val climate_1 climate_1
ren climate_1 climatechg1
label var climatechg1 "Climate change is not a serious problem."
replace climate_2="0" if climate_2=="Definitely Disagree"
replace climate_2="1" if climate_2=="Somewhat Disagree"
replace climate_2="2" if climate_2=="Neither Agree Nor Disagree"
replace climate_2="3" if climate_2=="Somewhat Agree"
replace climate_2="4" if climate_2=="Definitely Agree"
destring climate_2, replace
label define climate_2 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_2 climate_2
ren climate_2 climatechg2
label var climatechg2 "Climate change will have a serious impact during my lifetime."
replace climate_3="0" if climate_3=="Definitely Disagree"
replace climate_3="1" if climate_3=="Somewhat Disagree"
replace climate_3="2" if climate_3=="Neither Agree Nor Disagree"
replace climate_3="3" if climate_3=="Somewhat Agree"
replace climate_3="4" if climate_3=="Definitely Agree"
destring climate_3, replace
label define climate_3 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_3 climate_3
ren climate_3 climatechg3
label var climatechg3 "I would vote for a politician who promised to take action to address climate change."
replace climate_5="0" if climate_5=="Definitely Agree"
replace climate_5="1" if climate_5=="Somewhat Agree"
replace climate_5="2" if climate_5=="Neither Agree Nor Disagree"
replace climate_5="3" if climate_5=="Somewhat Disagree"
replace climate_5="4" if climate_5=="Definitely Disagree"
destring climate_5, replace
label define climate_5 0 "Agree" 1 "Somewhat Agree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Disagree" 4 "Disagree"
label val climate_5 climate_5
ren climate_5 climatechg4
order climatechg4, b(climate_4)
label var climatechg4 "The U.S. should not do more to reduce climate change."
replace climate_6="0" if climate_6=="Definitely Disagree"
replace climate_6="1" if climate_6=="Somewhat Disagree"
replace climate_6="2" if climate_6=="Neither Agree Nor Disagree"
replace climate_6="3" if climate_6=="Somewhat Agree"
replace climate_6="4" if climate_6=="Definitely Agree"
destring climate_6, replace
label define climate_6 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_6 climate_6
ren climate_6 climatechg5
order climatechg5, b(climate_4)
label var climatechg5 "The international community should do more to reduce climate change."
replace climate_4="0" if climate_4=="Definitely Disagree"
replace climate_4="1" if climate_4=="Somewhat Disagree"
replace climate_4="2" if climate_4=="Neither Agree Nor Disagree"
replace climate_4="3" if climate_4=="Somewhat Agree"
replace climate_4="4" if climate_4=="Definitely Agree"
destring climate_4, replace
label define climate_4 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_4 climate_4
ren climate_4 climatechg6
label var climatechg6 "I would personally support a tax increase to fund national programs to reduce climate change."
foreach x of var climatechg1 climatechg2 climatechg3 climatechg4 climatechg5 climatechg6 {
gen `x'_high=(`x'>=3)
order `x'_high, b(`x')
}
label var climatechg1_high "Climate change is not a serious problem."
label var climatechg2_high "Climate change will have a serious impact during my lifetime."
label var climatechg3_high "I would vote for a politician who promised to take action to reduce climate change."
label var climatechg4_high "The U.S. should not do more to reduce climate change."
label var climatechg5_high "The international community should do more to reduce climate change."
label var climatechg6_high "I would personally support a tax increase to fund national programs to reduce climate change."

replace climate_7="0" if climate_7=="Definitely Disagree"
replace climate_7="1" if climate_7=="Somewhat Disagree"
replace climate_7="2" if climate_7=="Neither Agree Nor Disagree"
replace climate_7="3" if climate_7=="Somewhat Agree"
replace climate_7="4" if climate_7=="Definitely Agree"
destring climate_7, replace
label define climate_7 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_7 climate_7
ren climate_7 anthropogenic
label var anthropogenic "Human activities are the main cause of climate change."
gen anthropogenic_agree=(anthropogenic>=3)
order anthropogenic_agree, a(anthropogenic)
label var anthropogenic_agree "Agree Humans Cause Climate Change"

replace climate_8="0" if climate_8=="Definitely Disagree"
replace climate_8="1" if climate_8=="Somewhat Disagree"
replace climate_8="2" if climate_8=="Neither Agree Nor Disagree"
replace climate_8="3" if climate_8=="Somewhat Agree"
replace climate_8="4" if climate_8=="Definitely Agree"
destring climate_8, replace
label define climate_8 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_8 climate_8
ren climate_8 hurricane_cause
label var hurricane_cause "Hurricanes are caused by climate change."
gen hurricane_cause_agree=(hurricane_cause>=3)
order hurricane_cause_agree, a(hurricane_cause)
label var hurricane_cause_agree "Agree Climate Change Causes Hurricanes"
replace climate_9="0" if climate_9=="Definitely Disagree"
replace climate_9="1" if climate_9=="Somewhat Disagree"
replace climate_9="2" if climate_9=="Neither Agree Nor Disagree"
replace climate_9="3" if climate_9=="Somewhat Agree"
replace climate_9="4" if climate_9=="Definitely Agree"
destring climate_9, replace
label define climate_9 0 "Disagree" 1 "Somewhat Disagree" 2 "Neither Agree Nor Disagree" 3 "Somewhat Agree" 4 "Agree"
label val climate_9 climate_9
ren climate_9 hurricane_worse
label var hurricane_worse "Hurricanes are worsened by climate change."
gen hurricane_worse_agree=(hurricane_worse>=3)
order hurricane_worse_agree, a(hurricane_worse)
label var hurricane_worse_agree "Agree Climate Change Worsens Hurricanes"

replace cc_costs_1="0" if cc_costs_1=="$0 "
replace cc_costs_1="1" if cc_costs_1=="$1-$49"
replace cc_costs_1="2" if cc_costs_1=="$50-99"
replace cc_costs_1="3" if cc_costs_1=="$100 or greater"
destring cc_costs_1, replace
label define cc_costs_1 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_1 cc_costs_1
ren cc_costs_1 tax_migjob
label var tax_migjob "Tax Increase to Fund: Migrant Job Training"
replace cc_costs_2="0" if cc_costs_2=="$0 "
replace cc_costs_2="1" if cc_costs_2=="$1-$49"
replace cc_costs_2="2" if cc_costs_2=="$50-99"
replace cc_costs_2="3" if cc_costs_2=="$100 or greater"
destring cc_costs_2, replace
label define cc_costs_2 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_2 cc_costs_2
ren cc_costs_2 tax_border
label var tax_border "Tax Increase to Fund: Border Security"
replace cc_costs_3="0" if cc_costs_3=="$0 "
replace cc_costs_3="1" if cc_costs_3=="$1-$49"
replace cc_costs_3="2" if cc_costs_3=="$50-99"
replace cc_costs_3="3" if cc_costs_3=="$100 or greater"
destring cc_costs_3, replace
label define cc_costs_3 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_3 cc_costs_3
ren cc_costs_3 tax_usclimmig
label var tax_usclimmig "Tax Increase to Fund: Resettle Internal Climate Migrants"
replace cc_costs_4="0" if cc_costs_4=="$0 "
replace cc_costs_4="1" if cc_costs_4=="$1-$49"
replace cc_costs_4="2" if cc_costs_4=="$50-99"
replace cc_costs_4="3" if cc_costs_4=="$100 or greater"
destring cc_costs_4, replace
label define cc_costs_4 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_4 cc_costs_4
ren cc_costs_4 tax_intlclimmig
label var tax_intlclimmig "Tax Increase to Fund: Resettle International Climate Migrants"
replace cc_costs_5="0" if cc_costs_5=="$0 "
replace cc_costs_5="1" if cc_costs_5=="$1-$49"
replace cc_costs_5="2" if cc_costs_5=="$50-99"
replace cc_costs_5="3" if cc_costs_5=="$100 or greater"
destring cc_costs_5, replace
label define cc_costs_5 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_5 cc_costs_5
ren cc_costs_5 tax_carbon
label var tax_carbon "Tax Increase to Fund: Carbon Tax"
replace cc_costs_6="0" if cc_costs_6=="$0 "
replace cc_costs_6="1" if cc_costs_6=="$1-$49"
replace cc_costs_6="2" if cc_costs_6=="$50-99"
replace cc_costs_6="3" if cc_costs_6=="$100 or greater"
destring cc_costs_6, replace
label define cc_costs_6 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_6 cc_costs_6
ren cc_costs_6 tax_cleanenergy
label var tax_cleanenergy "Tax Increase to Fund: Clean Energy"
replace cc_costs_7="0" if cc_costs_7=="$0 "
replace cc_costs_7="1" if cc_costs_7=="$1-$49"
replace cc_costs_7="2" if cc_costs_7=="$50-99"
replace cc_costs_7="3" if cc_costs_7=="$100 or greater"
destring cc_costs_7, replace
label define cc_costs_7 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_7 cc_costs_7
ren cc_costs_7 tax_minrestrict
label var tax_minrestrict "Tax Increase to Fund: Restrictions on Oil/Coal"
replace cc_costs_8="0" if cc_costs_8=="$0 "
replace cc_costs_8="1" if cc_costs_8=="$1-$49"
replace cc_costs_8="2" if cc_costs_8=="$50-99"
replace cc_costs_8="3" if cc_costs_8=="$100 or greater"
destring cc_costs_8, replace
label define cc_costs_8 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_8 cc_costs_8
ren cc_costs_8 tax_milclim
label var tax_milclim "Tax Increase to Fund: Protecting Military from Climate Change"
replace cc_costs_9="0" if cc_costs_9=="$0 "
replace cc_costs_9="1" if cc_costs_9=="$1-$49"
replace cc_costs_9="2" if cc_costs_9=="$50-99"
replace cc_costs_9="3" if cc_costs_9=="$100 or greater"
destring cc_costs_9, replace
label define cc_costs_9 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_9 cc_costs_9
ren cc_costs_9 tax_fueleff
label var tax_fueleff "Tax Increase to Fund: Fuel Efficiency Standards"
replace cc_costs_10="0" if cc_costs_10=="$0 "
replace cc_costs_10="1" if cc_costs_10=="$1-$49"
replace cc_costs_10="2" if cc_costs_10=="$50-99"
replace cc_costs_10="3" if cc_costs_10=="$100 or greater"
destring cc_costs_10, replace
label define cc_costs_10 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_10 cc_costs_10
ren cc_costs_10 tax_coast
label var tax_coast "Tax Increase to Fund: Coastal Protection"
replace cc_costs_11="0" if cc_costs_11=="$0 "
replace cc_costs_11="1" if cc_costs_11=="$1-$49"
replace cc_costs_11="2" if cc_costs_11=="$50-99"
replace cc_costs_11="3" if cc_costs_11=="$100 or greater"
destring cc_costs_11, replace
label define cc_costs_11 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_11 cc_costs_11
ren cc_costs_11 tax_flood
label var tax_flood "Tax Increase to Fund: Flood Retrofitting"
replace cc_costs_12="0" if cc_costs_12=="$0 "
replace cc_costs_12="1" if cc_costs_12=="$1-$49"
replace cc_costs_12="2" if cc_costs_12=="$50-99"
replace cc_costs_12="3" if cc_costs_12=="$100 or greater"
destring cc_costs_12, replace
label define cc_costs_12 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_12 cc_costs_12
ren cc_costs_12 tax_streetpump
label var tax_streetpump "Tax Increase to Fund: Raising Streets/Building Pumping Stations"
replace cc_costs_13="0" if cc_costs_13=="$0 "
replace cc_costs_13="1" if cc_costs_13=="$1-$49"
replace cc_costs_13="2" if cc_costs_13=="$50-99"
replace cc_costs_13="3" if cc_costs_13=="$100 or greater"
destring cc_costs_13, replace
label define cc_costs_13 0 "$0" 1 "$1-$49" 2 "$50-$99" 3 "$100+"
label val cc_costs_13 cc_costs_13
ren cc_costs_13 tax_windows
label var tax_windows "Tax Increase to Fund: Weather-Proofed Windows"
foreach x of var tax_* {
gen `x'_any=(`x'>0)
order `x'_any, b(`x')
}
label var tax_migjob_any "Tax Increase to Fund: Migrant Job Training"
label var tax_border_any "Tax Increase to Fund: Border Security"
label var tax_usclimmig_any "Tax Increase to Fund: Resettle Internal Climate Migrants"
label var tax_intlclimmig_any "Tax Increase to Fund: Resettle International Climate Migrants"
label var tax_carbon_any "Tax Increase to Fund: Carbon Tax"
label var tax_cleanenergy_any "Tax Increase to Fund: Clean Energy"
label var tax_minrestrict_any "Tax Increase to Fund: Restrictions on Oil/Coal"
label var tax_milclim_any "Tax Increase to Fund: Protecting Military from Climate Change"
label var tax_fueleff_any "Tax Increase to Fund: Fuel Efficiency Standards"
label var tax_coast_any "Tax Increase to Fund: Coastal Protection"
label var tax_flood_any "Tax Increase to Fund: Flood Retrofitting"
label var tax_streetpump_any "Tax Increase to Fund: Raising Streets/Building Pumping Stations"
label var tax_windows_any "Tax Increase to Fund: Weather-Proofed Windows"

gen implement_migjob=(cc_implementation_5!="")
label var implement_migjob "Locality Implemented: Migrant Job Training"
drop cc_implementation_4 cc_implementation_5
gen implement_border=(cc_implementation_8!="")
label var implement_border "Locality Implemented: Border Security"
drop cc_implementation_8
gen implement_usclimmig=(cc_implementation_13!="")
label var implement_usclimmig "Locality Implemented: Resettle Internal Climate Migrants"
drop cc_implementation_13
gen implement_intlclimmig=(cc_implementation_14!="")
label var implement_intlclimmig "Locality Implemented: Resettle International Climate Migrants"
drop cc_implementation_14
gen implement_carbon=(cc_implementation_16!="")
label var implement_carbon "Locality Implemented: Carbon Tax"
drop cc_implementation_16
gen implement_cleanenergy=(cc_implementation_15!="")
label var implement_cleanenergy "Locality Implemented: Clean Energy"
drop cc_implementation_15
gen implement_minrestrict=(cc_implementation_17!="")
label var implement_minrestrict "Locality Implemented: Restrictions on Oil/Coal"
drop cc_implementation_17
gen implement_milclim=(cc_implementation_18!="")
label var implement_milclim "Locality Implemented: Protecting Military from Climate Change"
drop cc_implementation_18
gen implement_fueleff=(cc_implementation_20!="")
label var implement_fueleff "Locality Implemented: Fuel Efficiency Standards"
drop cc_implementation_20
gen implement_coast=(cc_implementation_21!="")
label var implement_coast "Locality Implemented: Coastal Protection"
drop cc_implementation_21
gen implement_flood=(cc_implementation_22!="")
label var implement_flood "Locality Implemented: Flood Retrofitting"
drop cc_implementation_22
gen implement_streetpump=(cc_implementation_23!="")
label var implement_streetpump "Locality Implemented: Raising Streets/Building Pumping Stations"
drop cc_implementation_23
gen implement_windows=(cc_implementation_24!="")
label var implement_windows "Locality Implemented: Weather-Proofed Windows"
drop cc_implementation_24
order implement_migjob implement_border implement_usclimmig implement_intlclimmig implement_carbon implement_cleanenergy implement_minrestrict implement_milclim implement_fueleff implement_coast implement_flood implement_streetpump implement_windows, a(tax_windows)

replace rel_import_scale_1="0" if rel_import_scale_1=="Not a priority at all"
replace rel_import_scale_1="1" if rel_import_scale_1=="Slight priority"
replace rel_import_scale_1="2" if rel_import_scale_1=="Medium level priority"
replace rel_import_scale_1="3" if rel_import_scale_1=="Fairly high priority"
replace rel_import_scale_1="4" if rel_import_scale_1=="Top priority"
destring rel_import_scale_1, replace
label define rel_import_scale_1 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_1 rel_import_scale_1
ren rel_import_scale_1 priority_climchg
label var priority_climchg "Priority: Addressing Climate Change"
replace rel_import_scale_2="0" if rel_import_scale_2=="Not a priority at all"
replace rel_import_scale_2="1" if rel_import_scale_2=="Slight priority"
replace rel_import_scale_2="2" if rel_import_scale_2=="Medium level priority"
replace rel_import_scale_2="3" if rel_import_scale_2=="Fairly high priority"
replace rel_import_scale_2="4" if rel_import_scale_2=="Top priority"
destring rel_import_scale_2, replace
label define rel_import_scale_2 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_2 rel_import_scale_2
ren rel_import_scale_2 priority_climmig
label var priority_climmig "Priority: Addressing Climate Migration"
replace rel_import_scale_3="0" if rel_import_scale_3=="Not a priority at all"
replace rel_import_scale_3="1" if rel_import_scale_3=="Slight priority"
replace rel_import_scale_3="2" if rel_import_scale_3=="Medium level priority"
replace rel_import_scale_3="3" if rel_import_scale_3=="Fairly high priority"
replace rel_import_scale_3="4" if rel_import_scale_3=="Top priority"
destring rel_import_scale_3, replace
label define rel_import_scale_3 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_3 rel_import_scale_3
ren rel_import_scale_3 priority_migration
label var priority_migration "Priority: Addressing Migration"
replace rel_import_scale_4="0" if rel_import_scale_4=="Not a priority at all"
replace rel_import_scale_4="1" if rel_import_scale_4=="Slight priority"
replace rel_import_scale_4="2" if rel_import_scale_4=="Medium level priority"
replace rel_import_scale_4="3" if rel_import_scale_4=="Fairly high priority"
replace rel_import_scale_4="4" if rel_import_scale_4=="Top priority"
destring rel_import_scale_4, replace
label define rel_import_scale_4 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_4 rel_import_scale_4
ren rel_import_scale_4 priority_economy
label var priority_economy "Priority: Strengthening Economy"
replace rel_import_scale_5="0" if rel_import_scale_5=="Not a priority at all"
replace rel_import_scale_5="1" if rel_import_scale_5=="Slight priority"
replace rel_import_scale_5="2" if rel_import_scale_5=="Medium level priority"
replace rel_import_scale_5="3" if rel_import_scale_5=="Fairly high priority"
replace rel_import_scale_5="4" if rel_import_scale_5=="Top priority"
destring rel_import_scale_5, replace
label define rel_import_scale_5 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_5 rel_import_scale_5
ren rel_import_scale_5 priority_health
label var priority_health "Priority: Improving Healthcare System"
replace rel_import_scale_6="0" if rel_import_scale_6=="Not a priority at all"
replace rel_import_scale_6="1" if rel_import_scale_6=="Slight priority"
replace rel_import_scale_6="2" if rel_import_scale_6=="Medium level priority"
replace rel_import_scale_6="3" if rel_import_scale_6=="Fairly high priority"
replace rel_import_scale_6="4" if rel_import_scale_6=="Top priority"
destring rel_import_scale_6, replace
label define rel_import_scale_6 0 "Not a Priority" 1 "Slight Priority" 2 "Medium Priority" 3 "High Priority" 4 "Top Priority"
label val rel_import_scale_6 rel_import_scale_6
ren rel_import_scale_6 priority_military
label var priority_military "Priority: Strengthening Military"
foreach x of var priority_* {
gen `x'_high=(`x'>=3)
order `x'_high, b(`x')
}
label var priority_climchg_high "Priority: Addressing Climate Change"
label var priority_climmig_high "Priority: Addressing Climate Migration"
label var priority_migration_high "Priority: Addressing Migration"
label var priority_economy_high "Priority: Strengthening Economy"
label var priority_health_high "Priority: Improving Healthcare System"
label var priority_military_high "Priority: Strengthening Military"

swindex priority_climmig_high climatemig1_high climatemig2_high, gen(climmig_importance)
label var climmig_importance "Climate Migration Importance Index"
swindex climatemig3_high climatemig4_high climatemig5_high tax_usclimmig_any tax_intlclimmig_any, gen(climmig_action)
label var climmig_action "Climate Migration Action Index"
swindex priority_climchg_high climatechg1_high climatechg2_high, gen(climchg_importance)
label var climchg_importance "Climate Change Importance Index"
swindex climatechg3_high climatechg4_high climatechg5_high climatechg6_high, gen(climchg_action)
label var climchg_action "Climate Change Action Index"
order climmig_importance climmig_action climchg_importance climchg_action, a(priority_military)
swindex tax_milclim_any tax_coast_any tax_flood_any tax_streetpump_any tax_windows_any, gen(climchg_adaptation)
label var climchg_adaptation "Climate Change Adaptation Index"
swindex tax_carbon_any tax_cleanenergy_any tax_minrestrict_any tax_fueleff_any, gen(climchg_mitigation)
label var climchg_mitigation "Climate Change Mitigation Index"
swindex anthropogenic_agree hurricane_cause_agree hurricane_worse_agree, gen(climchg_science)
label var climchg_science "Climate Change Science Index"
order climchg_mitigation climchg_adaptation climchg_science, a(climchg_action)


********************************************************************************
*								CREATE POPWEIGHTS							   *
********************************************************************************

gen plus65=(age>=65)
gen plushs=(education>=1)
gen pluscollege=(education>=4)
ebalance plus65 woman race_white race_black race_indigenous race_asian race_latinx race_multi plushs pluscollege republican democrat, manualtargets(.168 .505 .758 .136 .016 .061 .189 .029 .889 .337 .470 .420)
ren _webal eweight
label var eweight "Entropy Weights"

ebalance plus65 woman race_white race_black race_indigenous race_asian race_latinx race_multi plushs pluscollege republican democrat, manualtargets(.15825 .513 .5225 .19025 .00425 .03225 .2075 .04375 .879 .319 .395 .425)
drop plus65 plushs pluscollege
ren _webal rweight
label var rweight "Entropy Weights -- 4 States"

sort respondent_id
save "${data}/Survey/followup_final.dta", replace

********************************************************************************
*								ADD CLIMATE DATA							   *
********************************************************************************

replace obsdrop=1 if respondent_id==13
replace obsdrop=1 if respondent_id==163
replace obsdrop=1 if respondent_id==180
replace obsdrop=1 if respondent_id==379
replace obsdrop=1 if respondent_id==182
replace obsdrop=1 if respondent_id==184
replace obsdrop=1 if respondent_id==198
replace obsdrop=1 if respondent_id==340
replace obsdrop=1 if respondent_id==819
replace geoid=12115 if respondent_id==603
replace statefp=12 if respondent_id==603
replace countyfp=115 if respondent_id==603
replace state="Florida" if respondent_id==603
replace county="Sarasota" if respondent_id==603
replace geoid=12127 if respondent_id==879
replace statefp=12 if respondent_id==879
replace countyfp=127 if respondent_id==879
replace state="Florida" if respondent_id==879
replace county="Volusia" if respondent_id==879
replace geoid=48141 if respondent_id==882
replace statefp=48 if respondent_id==882
replace countyfp=141 if respondent_id==882
replace state="Texas" if respondent_id==882
replace county="El Paso" if respondent_id==882

gen focalsample1=(state=="Florida" | state=="Louisiana" | state=="Texas")
label var focalsample1 "PAP Sample"
gen focalsample2=(state=="Florida" | state=="Louisiana" | state=="Texas" | state=="North Carolina")
label var focalsample2 "PAP Sample + NC"
replace obsdrop=1 if focalsample2==0
order focalsample1 focalsample2, a(priority_military)

gen post=(start_date>=22916)
label var post "Post-Hurricane Ian Landfall"
gen time2ian=start_date-22916
label var time2ian "Days Relative to Hurricane Ian Landfall"
gen postwave=(wave>=6)
label var postwave "Post-Hurricane Ian Landfall Wave"
gen wave2ian=wave-6
label var wave2ian "Waves Relative to Hurricane Ian Landfall"
gen postdynamic=0
replace postdynamic=1 if start_date>=22916 & state=="Florida"
replace postdynamic=1 if start_date>=22921 & state=="North Carolina"
label var postdynamic "Post-Hurricane Ian Landfall"
order postdynamic, a(post)
gen time2ian_dynamic=time2ian
replace time2ian_dynamic=start_date-22921 if state=="North Carolina"
label var time2ian_dynamic "Days Relative to Hurricane Ian Landfall"
order time2ian_dynamic, a(time2ian)

merge m:1 geoid using "${data}/Hurricane/ian_geo.dta"
drop if _m==2
drop regcomm
gen i_ian_deaths=(ian_deaths>0)
order i_ian_deaths, b(ian_deaths)
label var i_ian_deaths "Hurricane Ian Deaths (=1)"
replace i_ian_deaths=. if _m==1
drop _m
egen std_ian_death=std(ian_death)
label var std_ian_death "Hurricane Ian Deaths"
replace std_ian_death=. if i_ian_deaths==.
order std_ian_death, a(ian_deaths)
sort respondent_id

replace ian_windswath34=1 if ian_windswath64==1
replace ian_windswath50=1 if ian_windswath64==1
replace ian_windswath34=1 if ian_windswath50==1
label var ian_windswath34 "Hurricane Ian Tropical Storm-Force Windswath"
label var ian_windswath50 "Hurricane Ian Storm-Force Windswath"
label var ian_windswath64 "Hurricane Ian Hurricane-Force Windswath"

gen ian_windswath=0
replace ian_windswath=. if ian_windswath34==.
replace ian_windswath=1 if ian_windswath34==1
replace ian_windswath=2 if ian_windswath50==1
replace ian_windswath=2 if ian_windswath64==1
label var ian_windswath "Hurricane Ian Binary Windswath"
label define wind 0 "None" 1 "Tropical Storm" 2 "Storm"
label val ian_windswath wind
order ian_windswath, a(ian_windswath64)

gen ian_windswath2=0
replace ian_windswath2=. if ian_windswath34==.
replace ian_windswath2=1 if ian_windswath34==1
replace ian_windswath2=2 if ian_windswath50==1
replace ian_windswath2=3 if ian_windswath64==1
label var ian_windswath2 "Hurricane Ian Maximum Windswath"
label define windswath 0 "None" 1 "Tropical Storm" 2 "Storm" 3 "Hurricane"
label val ian_windswath2 windswath
order ian_windswath2, a(ian_windswath)

gen ian_cyclonic=(ian_windswath>0)
replace ian_cyclonic=. if ian_windswath==.
label var ian_cyclonic "Hurricane Ian Cyclonic Winds"
order ian_cyclonic, b(ian_windswath)

gen ian_distance_mi=((ian_distance)*111)*0.621371
order ian_distance_mi, a(ian_distance)
label var ian_distance_mi "Distance to Hurricane Ian Eyepath"

gen ian_proximity=1/ian_distance_mi
order ian_proximity, b(ian_distance)
label var ian_proximity "Hurricane Ian Proximity to Eyepath"
egen std_ian_proximity=std(ian_proximity)
order std_ian_proximity, b(ian_proximity)
label var std_ian_proximity "Hurricane Ian Proximity to Eyepath"
gen ian_prox1=(ian_distance_mi<=10)
label var ian_prox1 "Proximity to Eyepath: 0-10 Miles"
gen ian_prox2=(ian_distance_mi>10 & ian_distance_mi<=25)
label var ian_prox2 "Proximity to Eyepath: 10-25 Miles"
gen ian_prox3=(ian_distance_mi>25 & ian_distance_mi<=50)
label var ian_prox3 "Proximity to Eyepath: 25-50 Miles"
gen ian_prox4=(ian_distance_mi>50 & ian_distance_mi<=75)
label var ian_prox4 "Proximity to Eyepath: 50-75 Miles"
gen ian_prox5=(ian_distance_mi>75 & ian_distance_mi<=100)
label var ian_prox5 "Proximity to Eyepath: 75-100 Miles"
gen ian_prox6=(ian_distance_mi>100 & ian_distance_mi<=500)
label var ian_prox6 "Proximity to Eyepath: 100-500 Miles"
order ian_prox1-ian_prox6, a(ian_proximity)
foreach x of var ian_prox1-ian_prox6 {
replace `x'=. if ian_distance==.
}

gen i_ian_surge=(ian_surge>=1)
replace i_ian_surge=. if ian_surge==.
order i_ian_surge, a(ian_surge)
label var i_ian_surge  "Hurricane Ian Storm Surge (=1)"
order ian_surge i_ian_surge, a(ian_evacuation)

gen ian_eyepath_broad=ian_eyepath
replace ian_eyepath_broad=1 if geoid==12081 | geoid==12027 | geoid==12055 | geoid==37153 | geoid==12049 | geoid==37167 | geoid==37123 | geoid==12095 | geoid==37125 | geoid==12043 | geoid==12097 | geoid==37037 | geoid==37007 | geoid==12071 | geoid==12115 | geoid==37047 | geoid==12009 | geoid==12105 | geoid==37093 | geoid==37165 | geoid==12093 | geoid==12015 | geoid==12061 | geoid==12127 | geoid==37155 | geoid==37151
label var ian_eyepath_broad "Hurricane Ian Eyepath + 26mi Buffer"
order ian_eyepath_broad, a(ian_eyepath)

sort respondent_id
save "${data}/Survey/followup_final.dta", replace

import delimited "${data}/Hurricane/ian_waze.csv", clear

gen ian_waze=1
collapse (sum) ian_waze, by(geoid)
tempfile waze
save `waze'

use "${data}/Survey/followup_final.dta", clear

merge m:1 geoid using `waze'
drop if _m==2
replace ian_waze=0 if state=="Florida" & _m==1
replace ian_waze=0 if (state=="Texas" | state=="Louisiana") & _m==1
replace ian_waze=. if state=="North Carolina" & _m==1
label var ian_waze "Hurricane Ian Road Incidents"
gen i_ian_waze=(ian_waze>0)
order i_ian_waze, b(ian_waze)
label var i_ian_waze "Hurricane Ian Road Incident (=1)"
replace i_ian_waze=. if ian_waze==.
order i_ian_waze ian_waze, a(fema_aid)
drop _m

gen i_fema_aid=(fema_aid>=1)
label var i_fema_aid "Hurricane Ian FEMA Assistance (=1)"
order i_fema_aid, b(fema_aid)
gen indiv_fema_aid=(fema_aid>=3)
label var indiv_fema_aid "Hurricane Ian FEMA Individual Assistance (=1)"
order indiv_fema_aid, a(fema_aid)

order emg_command, a(statefp)

swindex ian_surge ian_windswath ian_eyepath, gen(hurricane_index1)
label var hurricane_index1 "Hurricane Exposure Index"
swindex ian_surge ian_windswath ian_eyepath ian_evacuation ian_deaths, gen(hurricane_index2)
label var hurricane_index2 "Hurricane Exposure Index"
replace hurricane_index1=. if ian_surge==.
replace hurricane_index2=. if ian_surge==.

compress
sort respondent_id
save "${data}/Survey/followup_final.dta", replace

merge m:1 geoid using "${data}/Hurricane/nicole_geo.dta"
drop if _m==2
drop _m
sort respondent_id

replace nicole_windswath34=1 if nicole_windswath64==1
replace nicole_windswath50=1 if nicole_windswath64==1
replace nicole_windswath34=1 if nicole_windswath50==1
label var nicole_windswath34 "Hurricane Nicole Tropical Storm-Force Windswath"
label var nicole_windswath50 "Hurricane Nicole Storm-Force Windswath"
label var nicole_windswath64 "Hurricane Nicole Hurricane-Force Windswath"

gen nicole_windswath=0
replace nicole_windswath=. if focalsample2==0
replace nicole_windswath=1 if nicole_windswath34==1
replace nicole_windswath=2 if nicole_windswath50==1
replace nicole_windswath=2 if nicole_windswath64==1
label var nicole_windswath "Hurricane Nicole Binary Windswath"
label val nicole_windswath wind
order nicole_windswath, a(nicole_windswath64)

gen nicole_windswath2=0
replace nicole_windswath2=. if focalsample2==0
replace nicole_windswath2=1 if nicole_windswath34==1
replace nicole_windswath2=2 if nicole_windswath50==1
replace nicole_windswath2=3 if nicole_windswath64==1
label var nicole_windswath2 "Hurricane Nicole Maximum Windswath"
label val nicole_windswath2 windswath
order nicole_windswath2, a(nicole_windswath)

gen nicole_cyclonic=(nicole_windswath>0)
replace nicole_cyclonic=. if nicole_windswath==.
label var nicole_cyclonic "Hurricane Nicole Cyclonic Winds"
order nicole_cyclonic, b(nicole_windswath)

foreach x of var nicole_windswath34 nicole_windswath50 nicole_windswath64 nicole_cyclonic nicole_windswath nicole_windswath2 {
replace `x'=. if focalsample2==0
}

replace nicole_eyepath=. if focalsample2==0
gen nicole_distance_mi=((nicole_distance)*111)*0.621371
order nicole_distance_mi, a(nicole_distance)
label var nicole_distance_mi "Distance to Hurricane Nicole Eyepath"

gen nicole_proximity=1/nicole_distance_mi
order nicole_proximity, b(nicole_distance)
label var nicole_proximity "Hurricane Nicole Proximity to Eyepath"
egen std_nicole_proximity=std(nicole_proximity)
order std_nicole_proximity, b(nicole_proximity)
label var std_nicole_proximity "Hurricane Nicole Proximity to Eyepath"

replace nicole_surge=. if focalsample2==0
gen i_nicole_surge=(nicole_surge>=1)
replace i_nicole_surge=. if nicole_surge==.
order i_nicole_surge, a(nicole_surge)
label var i_nicole_surge  "Hurricane Nicole Storm Surge (=1)"
order nicole_surge i_nicole_surge, a(nicole_windswath2)

swindex nicole_surge nicole_windswath nicole_eyepath, gen(nicole_index1)
label var nicole_index1 "Hurricane Nicole Exposure Index"

gen binary_nicoleindex1=(nicole_index1>-.6569326)
replace binary_nicoleindex1=. if nicole_index1==.
label var binary_nicoleindex1 "Hurricane Nicole Exposure Index (=1)"
order binary_nicoleindex1, a(nicole_index1)

compress
sort respondent_id
save "${data}/Survey/followup_final.dta", replace

********************************************************************************
*								ADD RELIEF DATA							   *
********************************************************************************

use "${data}/Covariates/ian_assistance.dta", clear

tempfile relief
save `relief'

use "${data}/Survey/followup_final.dta", clear

merge m:1 geoid using `relief'
drop if _m==2
drop _m
foreach x of var hh ihpAmount fipAmount haAmount onaAmount rpfvl ppfvl utilitiesOut homeDamage autoDamage emergencyNeeds foodNeed shelterNeed accessFunctionalNeeds sbaApproved tsaEligible tsaCheckedIn rentalAssistanceEligible repairAssistanceEligible replacementAssistanceEligible personalPropertyEligible numberactiveprojects currentprojectcost numberobligatedprojects federalshareobligated {
replace `x'=0 if `x'==.
replace `x'=. if geoid==.
}

gen open=(ian_claims_openpay+ian_claims_opennopay)/ian_claims
gen closed=(ian_claims_closedpay + ian_claims_closednopay)/ian_claims
gen paid=(ian_claims_openpay + ian_claims_closedpay)/ian_claims
foreach x of var open closed paid {
replace `x'=. if ian_claims==.
}
label var open "Share of Insurance Claims Open"
label var closed "Share of Insurance Claims Closed"
label var paid "Share of Insurance Claims Paid"
gen individual=(ihpAmount>0)
replace individual=. if ihpAmount==.
gen public=(numberobligatedprojects >0)
replace public=. if numberobligatedprojects==.
gen relief=(individual==1 | public==1)
replace relief=. if individual==.
replace relief=. if public==.
label var individual "Individual FEMA Assistance Provided (=1)"
label var public "Public FEMA Assistance Provided (=1)"
label var relief "Any FEMA Assistance Provided (=1)"

compress
sort respondent_id
save "${data}/Survey/followup_final.dta", replace

********************************************************************************
*								ADD ELECTION DATA							   *
********************************************************************************

import delimited "${data}/Covariates/countypres_2000-2020.csv", clear

keep if year==2020
ren county_fips geoid
replace geoid=11001 if state=="DISTRICT OF COLUMBIA"
drop if geoid==.
collapse (sum) candidatevotes (max) totalvotes, by(geoid party)
gen voteshare= candidatevotes/totalvotes
gen demvote20= voteshare if party=="DEMOCRAT"
gen repvote20= voteshare if party=="REPUBLICAN"
collapse (max) demvote20 repvote20, by(geoid)
tempfile vote
save `vote'

use "${data}/Survey/followup_final.dta", clear

merge m:1 geoid using `vote'
drop if _m==2
drop _m
label var demvote20 "2020 Democratic Voteshare"
label var repvote20 "2020 Republican Voteshare"
gen trump20=(repvote20>.50)
replace trump20=. if repvote20==.
order trump20, a(repvote20)
label var trump20 "Trump Won in 2020"

compress
sort respondent_id
save "${data}/Survey/followup_final.dta", replace

********************************************************************************
*								ADD POPULATION DATA							   *
********************************************************************************

import delimited "${data}/Covariates/pop2021.csv", clear

keep stname ctyname popestimate2021 domesticmig2021 internationalmig2021 netmig2021
ren stname state
ren ctyname county
gen dmig2021=domesticmig2021/popestimate2021
gen imig2021=internationalmig2021/popestimate2021
gen nmig2021=netmig2021/popestimate2021
drop if state==county

tempfile mappop
save `mappop'

replace county = subinstr(county, " County", "", .)
replace county = subinstr(county, " Parish", "", .)
replace county = subinstr(county, " Borough", "", .)
replace county = subinstr(county, " Census Area", "", .)
replace county = subinstr(county, " city", " City", .)
replace county="Norfolk" if county=="Norfolk City"
replace county="Chesapeake" if county=="Chesapeake City"

tempfile pop
save `pop'

use "${data}/Survey/followup_final.dta", clear

merge m:1 state county using `pop'
drop if _m==2
drop _m internationalmig2021 domesticmig2021 netmig2021

ren popestimate2021 pop2021
label var pop2021 "2021 Population"
label var dmig2021 "2021 Domestic Migration Rate"
label var imig2021 "2021 International Migration Rate"
label var nmig2021 "2021 Net Migration Rate"
gen pop1000=pop2021/1000
replace ian_waze=(ian_waze/pop1000)
drop pop1000

gen ian_waze50=(ian_waze>=3.024386)
label var ian_waze50 "Hurricane Ian Road Incidents (Top 50 %Tile)"
gen ian_waze75=(ian_waze>=3.80126)
label var ian_waze75 "Hurricane Ian Road Incidents (Top 25 %Tile)"
gen ian_waze90=(ian_waze>=5.740373)
label var ian_waze90 "Hurricane Ian Road Incidents (Top 10 %Tile)"
replace ian_waze50=. if ian_waze==.
replace ian_waze75=. if ian_waze==.
replace ian_waze90=. if ian_waze==.
order ian_waze50 ian_waze75 ian_waze90, a(ian_waze)

compress
sort respondent_id
save "${data}/Survey/followup_final.dta", replace

********************************************************************************
*								MAP DESCRIPTIVES							   *
********************************************************************************

keep if focalsample2==1
keep geoid
gen response2=1

collapse (sum) response2, by(geoid)

tempfile followup
save `followup'

use "${data}/Survey/map_descriptives.dta", clear

merge 1:1 geoid using `followup'
drop if _m==2
replace response2=0 if _m==1
drop _m

gen response_all=response+response2
label var response2 "Follow-Up Responses"
label var response_all "Pooled Responses"

merge m:1 geoid using `relief'
drop if _m==2
drop _m
foreach x of var hh ihpAmount fipAmount haAmount onaAmount rpfvl ppfvl utilitiesOut homeDamage autoDamage emergencyNeeds foodNeed shelterNeed accessFunctionalNeeds sbaApproved tsaEligible tsaCheckedIn rentalAssistanceEligible repairAssistanceEligible replacementAssistanceEligible personalPropertyEligible numberactiveprojects currentprojectcost numberobligatedprojects federalshareobligated {
replace `x'=0 if `x'==.
replace `x'=. if geoid==.
}

gen open=(ian_claims_openpay+ian_claims_opennopay)/ian_claims
gen closed=(ian_claims_closedpay + ian_claims_closednopay)/ian_claims
gen paid=(ian_claims_openpay + ian_claims_closedpay)/ian_claims
foreach x of var open closed paid {
replace `x'=. if ian_claims==.
}
label var open "Share of Insurance Claims Open"
label var closed "Share of Insurance Claims Closed"
label var paid "Share of Insurance Claims Paid"
gen individual=(ihpAmount>0)
replace individual=. if ihpAmount==.
gen public=(numberobligatedprojects >0)
replace public=. if numberobligatedprojects==.
gen relief=(individual==1 | public==1)
replace relief=. if individual==.
replace relief=. if public==.
label var individual "Individual FEMA Assistance Provided (=1)"
label var public "Public FEMA Assistance Provided (=1)"
label var relief "Any FEMA Assistance Provided (=1)"
gen obligated=federalshareobligated/numberobligatedprojects
replace obligated=0 if numberobligatedprojects==0
label var obligated "Obligated Money per Project (=1)"

compress
sort geoid
save "${data}/Survey/map_descriptives.dta", replace

********************************************************************************
*								BALLOT INITIATIVES							   *
********************************************************************************

import excel "${data}/Covariates/florida_ballots.xlsx", sheet("Flood Tax Amendment") firstrow clear

ren County county
ren YesforApproval flood_yesapprove
ren NoforRejection flood_noreject

drop if county=="Total" | county==""
gen flood_total=flood_yesapprove+flood_noreject
replace flood_yesapprove=flood_yesapprove/flood_total
replace flood_noreject=flood_noreject/flood_total
gen flood_pass=(flood_yesapprove>=.6)
drop flood_total

label var county "County"
label var flood_yesapprove "% Approve Flood Tax Amendment"
label var flood_noreject "% Reject Flood Tax Amendment"
label var flood_pass "Pass Flood Tax Amendment w/ Needed Supermajority"

tempfile flood
save `flood'

import excel "${data}/Covariates/florida_ballots.xlsx", sheet("Const. Revision Amendment") firstrow clear

ren County county
ren YesforApproval const_yesapprove
ren NoforRejection const_noreject

drop if county=="Total" | county==""
gen const_total=const_yesapprove+const_noreject
replace const_yesapprove=const_yesapprove/const_total
replace const_noreject=const_noreject/const_total
gen const_pass=(const_yesapprove>=.6)
drop const_total

label var county "County"
label var const_yesapprove "% Approve Abolish the Constitution Revision Commission"
label var const_noreject "% Reject Abolish the Constitution Revision Commission"
label var const_pass "Pass Abolish the Constitution Revision Commission w/ Needed Supermajority"

tempfile revision
save `revision'

import excel "${data}/Covariates/florida_ballots.xlsx", sheet("Homestead Tax Amendment") firstrow clear

ren County county
ren YesforApproval home_yesapprove
ren NoforRejection home_noreject
drop D

drop if county=="Total" | county==""
gen home_total=home_yesapprove+home_noreject
replace home_yesapprove=home_yesapprove/home_total
replace home_noreject=home_noreject/home_total
gen home_pass=(home_yesapprove>=.6)
drop home_total

label var county "County"
label var home_yesapprove "% Approve Homestead Property Tax Exemption"
label var home_noreject "% Reject Homestead Property Tax Exemption"
label var home_pass "Pass Homestead Property Tax Exemption w/ Needed Supermajority"

tempfile homestead
save `homestead'

import excel "${data}/Covariates/florida_ballots.xlsx", sheet("Governor") firstrow clear

ren County county
ren Republican republican
ren Democratic democratic
ren Libertarian libertarian
ren Other other
drop F

drop if county=="Total" | county==""
gen vote_total=republican+democratic+libertarian+other
gen dem_voteshare=democratic/vote_total
gen rep_voteshare=republican/vote_total
gen dem_majority=(dem_voteshare>=.5)
drop republican democratic libertarian other

label var county "County"
label var dem_voteshare "Democratic Voteshare for Governor"
label var rep_voteshare "Republican Voteshare for Governor"
label var dem_majority "Democratic Majority for Governor"
label var vote_total "Vote Total for Governor"

replace county = subinstr(county, " County", "",.) 
replace county = "Desoto" if county=="DeSoto"

tempfile governor
save `governor'

import excel "${data}/Covariates/florida_ballots.xlsx", sheet("Senate") firstrow clear

ren County county
ren Republican republican
ren Democratic democratic
ren Libertarian libertarian
ren Other1 other1
ren Other2 other2
ren Other3 other3
ren Other4 other4
ren Other5 other5
ren Other6 other6
gen other=(other1+other2+other3+other4+other5+other6)
drop other1-other6

drop if county=="Total" | county==""
gen votesen_total=republican+democratic+libertarian+other
gen demsen_voteshare=democratic/votesen_total
gen repsen_voteshare=republican/votesen_total
gen demsen_majority=(demsen_voteshare>=.5)
drop republican democratic libertarian other

label var county "County"
label var demsen_voteshare "Democratic Voteshare for Senate"
label var repsen_voteshare "Republican Voteshare for Senate"
label var demsen_majority "Democratic Majority for Senate"
label var votesen_total "Vote Total for Senate"

replace county = subinstr(county, " County", "",.) 
replace county = "Desoto" if county=="DeSoto"

tempfile senate
save `senate'

import excel "${data}/Covariates/florida_ballots.xlsx", sheet("Turnout") firstrow clear

ren County county
ren GeneralRegistered generalregister
ren GeneralTurnout generalturnout
ren PrimaryRegistered primaryregister
ren PrimaryTurnout primaryturnout

drop if county=="Total" | county==""
drop F G H I
gen genturnout=generalturnout/generalregister
gen primturnout=primaryturnout/primaryregister
gen genprimreg=generalregister-primaryregister
drop generalturnout primaryturnout primaryregister

label var county "County"
label var genturnout "% of Registered Voters Turned Out in General Election"
label var primturnout "% of Registered Voters Turned Out in Primary Election"
label var genprimreg "Change in # Registered Voters (Primary-->General)"

replace county = subinstr(county, " County", "",.) 

tempfile turnout
save `turnout'

import excel "${data}/Covariates/florida_ballots.xlsx", sheet("VAP") firstrow clear

ren County county
ren age18plus_tot vapop

drop if county=="Total" | county==""
drop E F

label var county "County"
label var vapop "Voting Age Population"
label var income "2021 Per Capita Income"
label var white "2020 White Population Share"

replace county = subinstr(county, " County", "",.) 
replace county = "Desoto" if county=="DeSoto"

tempfile vap
save `vap'

merge 1:1 county using `turnout'
drop _m
merge 1:1 county using `governor'
drop _m
merge 1:1 county using `senate'
drop _m
merge 1:1 county using `flood'
drop _m
merge 1:1 county using `revision'
drop _m
merge 1:1 county using `homestead'
drop _m

gen govturnout=vote_total/generalregister
label var govturnout "% of Registered Voters Turned Out in Gubernatorial Election"
gen govsenturnout=votesen_total/generalregister
label var govsenturnout "% of Registered Voters Turned Out in Senate Election"
drop generalregister

gen vapturnout=vote_total/vapop
label var vapturnout "% of Voting Age Population Turned Out in Gubernatorial Election"
gen vapsenturnout=votesen_total/vapop
label var vapsenturnout "% of Voting Age Population Turned Out in Senate Election"

compress
tempfile ballot
save `ballot'

use "${data}/Hurricane/ian_geo.dta", clear
drop regcomm

replace ian_windswath34=1 if ian_windswath64==1
replace ian_windswath50=1 if ian_windswath64==1
replace ian_windswath34=1 if ian_windswath50==1
label var ian_windswath34 "Hurricane Ian Tropical Storm-Force Windswath"
label var ian_windswath50 "Hurricane Ian Storm-Force Windswath"
label var ian_windswath64 "Hurricane Ian Hurricane-Force Windswath"

gen ian_windswath=0
replace ian_windswath=. if ian_windswath34==.
replace ian_windswath=1 if ian_windswath34==1
replace ian_windswath=2 if ian_windswath50==1
replace ian_windswath=2 if ian_windswath64==1
label var ian_windswath "Hurricane Ian Binary Windswath"
label define wind 0 "None" 1 "Tropical Storm" 2 "Storm"
label val ian_windswath wind
order ian_windswath, a(ian_windswath64)

gen ian_windswath2=0
replace ian_windswath2=. if ian_windswath34==.
replace ian_windswath2=1 if ian_windswath34==1
replace ian_windswath2=2 if ian_windswath50==1
replace ian_windswath2=3 if ian_windswath64==1
label var ian_windswath2 "Hurricane Ian Maximum Windswath"
label define windswath 0 "None" 1 "Tropical Storm" 2 "Storm" 3 "Hurricane"
label val ian_windswath2 windswath
order ian_windswath2, a(ian_windswath)

gen ian_cyclonic=(ian_windswath>0)
replace ian_cyclonic=. if ian_windswath==.
label var ian_cyclonic "Hurricane Ian Cyclonic Winds"
order ian_cyclonic, b(ian_windswath)

gen ian_distance_mi=((ian_distance)*111)*0.621371
order ian_distance_mi, a(ian_distance)
label var ian_distance_mi "Distance to Hurricane Ian Eyepath"

gen ian_proximity=1/ian_distance_mi
order ian_proximity, b(ian_distance)
label var ian_proximity "Hurricane Ian Proximity to Eyepath"
egen std_ian_proximity=std(ian_proximity)
order std_ian_proximity, b(ian_proximity)
label var std_ian_proximity "Hurricane Ian Proximity to Eyepath"

gen i_ian_surge=(ian_surge>=1)
replace i_ian_surge=. if ian_surge==.
order i_ian_surge, a(ian_surge)
label var i_ian_surge  "Hurricane Ian Storm Surge (=1)"
order ian_surge i_ian_surge, a(ian_evacuation)

gen ian_eyepath_broad=ian_eyepath
replace ian_eyepath_broad=1 if geoid==12081 | geoid==12027 | geoid==12055 | geoid==37153 | geoid==12049 | geoid==37167 | geoid==37123 | geoid==12095 | geoid==37125 | geoid==12043 | geoid==12097 | geoid==37037 | geoid==37007 | geoid==12071 | geoid==12115 | geoid==37047 | geoid==12009 | geoid==12105 | geoid==37093 | geoid==37165 | geoid==12093 | geoid==12015 | geoid==12061 | geoid==12127 | geoid==37155 | geoid==37151
label var ian_eyepath_broad "Hurricane Ian Eyepath + 26mi Buffer"
order ian_eyepath_broad, a(ian_eyepath)

gen i_fema_aid=(fema_aid>=1)
label var i_fema_aid "Hurricane Ian FEMA Assistance (=1)"
order i_fema_aid, b(fema_aid)
gen indiv_fema_aid=(fema_aid>=3)
label var indiv_fema_aid "Hurricane Ian FEMA Individual Assistance (=1)"
order indiv_fema_aid, a(fema_aid)

keep if state=="Florida" | state=="North Carolina" | state=="Texas" | state=="Louisiana"

swindex ian_surge ian_windswath ian_eyepath, gen(hurricane_index1)
label var hurricane_index1 "Hurricane Exposure Index"

replace county = subinstr(county, " County", "", .)
drop if state!="Florida"
replace county="Desoto" if county=="DeSoto"

tempfile ian_geo
save `ian_geo'

use `ballot'

merge 1:1 county using `ian_geo'
drop if _m==2
drop _m

order geoid county emg_command state
order hurricane_index1, a(home_pass)

sort geoid
save "${data}/Survey/florida_ballot.dta", replace

merge m:1 geoid using `vote'
drop if _m==2
drop _m
label var demvote20 "2020 Democratic Voteshare"
label var repvote20 "2020 Republican Voteshare"
gen trump20=(repvote20>.50)
replace trump20=. if repvote20==.
order trump20, a(repvote20)
label var trump20 "Trump Won in 2020"

compress
sort geoid
save "${data}/Survey/florida_ballot.dta", replace

use `pop', clear
keep if state=="Florida"
replace county="Desoto" if county=="DeSoto"

tempfile popfl
save `popfl'

use "${data}/Survey/florida_ballot.dta", clear

merge m:1 county using `popfl'
drop if _m==2
drop _m internationalmig2021 domesticmig2021 netmig2021

ren popestimate2021 pop2021
label var pop2021 "2021 Population"
label var dmig2021 "2021 Domestic Migration Rate"
label var imig2021 "2021 International Migration Rate"
label var nmig2021 "2021 Net Migration Rate"

compress
sort geoid
save "${data}/Survey/florida_ballot.dta", replace


********************************************************************************

